Here is the C++ program to find greatest number between three numbers. It takes input of three numbers from user and display the greatest. You all should have in mind how it works exactly. Here is the algorithm.
Steps
User side:
1: User asked to enter first number
2: User asked to enter second number
3: User asked to enter third number
4: Result is on screen
Developer side
1: Declare variables that are going to be used in program.
2: Input the first number from user.
3: Input the second number from user.
4: Input the third number from user.
5: Compare first and second numbers . If first is greater
6: Compare first and third numbers . If first is greater, declare first as greatest number.
7: If third number is greater, declare third as greatest number.
8: If first condition fails, declare second number as the greatest number.
9: Program ends here.
Here is the C++ program to find greatest number between three numbers. It takes input of three numbers from user and display the greatest. You all should have in mind how it works exactly. Here is the algorithm.
Steps
User side:
1: User asked to enter first number
Developer side
1: Declare variables that are going to be used in program.
2: Input the first number from user.
3: Input the second number from user.
4: Input the third number from user.
5: Compare first and second numbers . If first is greater
6: Compare first and third numbers . If first is greater, declare first as greatest number.
7: If third number is greater, declare third as greatest number.
8: If first condition fails, declare second number as the greatest number.
9: Program ends here.
Code:
#include<iostream>
using namespace std;
void
main()
{ //variable
declaration
int
a,b,c;
//input of
integer
cout<<"Input
first integer"<<endl;
cin>>a;
cout<<"Input
second integer"<<endl;
cin>>b;
cout<<"Input
first integer"<<endl;
cin>>c;
//Comparision
if(a>b)
{
if(a>c)
{
cout<<"First integer is greater"<<endl;
}
else
{
cout<<"Third integer is greater"<<endl;
}
}
else
{cout<<"Second integer is greater"<<endl;}
system("pause");
}

Comments
Post a Comment