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

Popular posts from this blog

Book-Shop Program using C++

Nesting of For Loop in C/C++

Switch statement in C/C++