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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: