C++ PROGRAMS
In the following program the user will enter 3 numbers and the output will be the greatest among these numbers.
In this I will use only if-else statements.
Code:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter 3 numbers: ";
cin>>a,b,c;
if(a>=b&&a>=c)
cout<<a;
else
if(b>=c&&b>=a)
cout<<b;
else
if(c>=a&&c>=b)
cout<<c;
cout<<" is greatest";
getch();
}
Output:
First Run:
Second Run:
For any queries or suggestions please comment
No comments:
Post a Comment