Check Your Age

08:52 0 Comments A+ a-

Problem:
Given an age in years, figure out whether someone's a baby, toddler, child, teenager, adult or old codger.
Title Ag (years)
Baby 0 to 3
Toddler 4 to 7
Child 8 to 12
Teenager 13 to 19
Adult or Old Codger 20 and above
Solution:
# include <iostream>
using namespace std;
int main()
{
int age; //Age initialized
cout<<"Please Enter the Age in Years:"<<endl;
cin>>age; //Age Declared after taking input from user

if(age>=20) //If-Elseif used for comparison of length
cout<<"Adult or Old Codger "<<endl; //After checking age is greater or equal to 20 will display Adult or Old codger
else if(age>=13)
cout<<"Teenager"<<endl; //After checking age is greater or equal to 13 will display Teenager
else if(age>=8)
cout<<"Child"<<endl; //After checking age is greater or equal to 8 will display Child
else if(age>=4)
cout<<"Toddler"<<endl; //After checking age is greater or equal to 4 will display Toddler
else if(age>=0)
cout<<"Baby"<<endl; //After checking age is greater or equal to 0 will display Baby


system("pause");
return 0;

}