Nested If-Else program in C/C++
Nested If-Else program in C/C++
This program is a "Nested If-Else" Program. In this program, we use a If-Else loop inside an If-Else loop. This program shows that whether you are a teenager, not a teenager, child or an old man.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int age;
cout << "Enter your age:";
cin >> age;
if(age>=10 && age<=50)
{
if(age>=10 && age<=18)
{
cout << "you are a teenager";
}
else
{
cout << "you are not a teenager";
}
}
else
{
if(age<10)
{
cout << "you are a child";
}
else
{
cout << "you are an old man";
}
}
}
Comments
Post a Comment