Friday, 5 July 2013

Accept age from the user and check the age.If the age is greater than 50 print OLD and if it is less then and equal to 50 it should print YOUNG.

#include<iostream>
using namespace std;
int main()
{
int age;
cout<<"Please enter your age: ";
cin>>age;
if(age>50)
{
cout<<"OLD";
}
else if(age>=0 && age<=50)
{
cout<<"YOUNG";
}
else
{
cout<<"Age cannot be negative.";
}
}

No comments:

Post a Comment