Monday, January 20, 2014

C++ Program for illustrating on InLine Function

with 0 Comment
#include<stdio.h>
#include<conio.h>
#include<math.h>
inline int big(int a,int b,int c)
{
return((a>b)?(a>c)?a:c:(b>c)?b:c);
}
int c;
inline int big1(int a,int b)
{
c=((a+b)+abs(a-b))/2;
return c;
}
void main()
{
int x,ch,a,b,c,d;
clrscr();
cout<<"\n Inline Function:";
cout<<"\n *********:";
cout<<"\n 1.Biggest of Two Numbers";
cout<<"\n 2.Biggest of Three Numbers";
cout<<"\n Enter our choice";
cin>>ch;
cout<<"\n Enter the First Value:";
cin>>a;
cout<<"\n Enter the Second Value:";
cin>>b;
switch(ch)
{
case 1:
c=big1(a,b);
cout<<"\n Biggest NUmber is:"<<c;
break;
case 2:
cout<<<"\n Enter the Third Value:";
cin>>c;
d=big(a,b,c);
cout<<"\n Biggest Number is:"<<d;
break;
}
getch();
}


-----------------------------------
OUTPUT:
-----------
Inline Function
***********
To Find Biggest Value
*****************
1.Biggest of Two Numbers
2.Biggest of Three Numbers

Enter our Choice1

Enter the First Choice:21

Enter the Second Value:23

Biggest Number is:23

To Find Biggest Value
*****************
1.Biggest of Two Numbers
2.Biggest of Threee Numbers

Enter our Choice:2

Enter the First value:21

Enter the Second value:23

Enter the Third Value:34

Biggest Number is:34

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive