//Program to determine youngest age
#include<iostream>
using namespace std;
class age
{
int a,b,c;
public:
void in()
{
cout<<"Enter the age of person 1: ";
cin>>a;
cout<<"Enter the age of person 2: ";
cin>>b;
cout<<"Enter the age of person 3: ";
cin>>c;
cout<<endl;
comp(a,b,c);
}
void comp(int x, int y, int z)
{
if((x<y) && (x<z))
cout<<"Youngest person is 'Person 1' with age "<<x<<" years";
else if((y<x) && (y<z))
cout<<"Youngest person is 'Person 2' with age "<<y<<" years";
else
cout<<"Youngest person is 'Person 3' with age "<<z<<" years";
}
};
int main(void)
{
age a;
a.in();
}
No comments:
Post a Comment
Comments please: