#include<iostream.h>
int main()
{
float num1,num2,num3,num4,num5,g,s;
cout<<" Enter the first number : ";
cin>>num1;
cout<<" Enter the second number : ";
cin>>num2;
cout<<" Enter the third number : ";
cin>>num3;
cout<<" Enter the fourth number : ";
cin>>num4;
cout<<" Enter the fifth number : ";
cin>>num5;
g = num1;
s = num1;
if(g<num2)
g = num2;
if(g<num3)
g = num3;
if(g<num4)
g = num4;
if(g<num5)
g = num5;
cout<<" The greatest number is "<<g<<endl;
if(s>num2)
s = num2;
if(s>num3)
s = num3;
if(s>num4)
s = num4;
if(s>num5)
s = num5;
cout<<" The smallest number is "<<s<<endl;
return 0;
}
Output:
Enter the first number : 1.5
Enter the second number : 3
Enter the third number : 9
Enter the fourth number : 0.35
Enter the fifth number : 9.1
The greatest number is 9.1
The smallest number is 0.35
Press any key to continue |