Write a C++ program to determine the youngest of the three, if the ages of A, B and C are input by the programmer.
Program Code:
#include<iostream>
using namespace std;
int main()
{
int A,B,C;
cout<<" Enter the ages of A : ";
cin>>A;
cout<<endl;
cout<<" Enter the ages of B : ";
cin>>B;
cout<<endl;
cout<<" Enter the ages of C : ";
cin>>C;
cout<<endl;
if((A>B)&&(A>C))
{
cout<<" the youngest of the three is A ";
cout<<A;
cout<<endl;
}
if((B>C)&&(B>A))
{
cout<<" the youngest of the three is B ";
cout<<B;
cout<<endl;
}
if((C>A)&&(C>B))
{
cout<<" the youngest of the three is C ";
cout<<C;
cout<<endl;
}
return 0;
}
The program output is tested on www.jdoodle.com
Output:
Enter the ages of A : 34
Enter the ages of B : 45
Enter the ages of C : 23
The youngest of the three is B 45
Thanks
Mukesh Rajput
Post A Comment:
0 comments: