Friday, 4 November 2016

Q. WAF to print greatest and smallest among 3 nos.

#include<conio.h>
#include<iostream.h>
int which_is_great(int a,int b,int c);
int which_is_small(int d,int e,int f);
void main()
{
clrscr();
int w,x,y,z,s;
cout<<"Enter 3 nos. ";
cin>>w>>x>>y;
z=which_is_great(w,x,y);
s=which_is_small(w,x,y);
cout<<"Greatest no. = "<<z<<"\n";
cout<<"Smallest no. = "<<s;
getch();
}
int which_is_great(int a,int b,int c)
{
int d;
d=a>b?(a>c?a:c):(b>c?b:c);
return (d);
}
int which_is_small(int d,int e,int f)
{
int a;
a=d<e?(d<f?d:f):(e<f?e:f);
return(a);
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...