Nested if else in C++ by R4R Team

What is if else?
-Basically in C++, if else is used to check check condition.
or if else are called as conditional statement in C or C++ language.

What is Nested if else?
When any 'if else' are come inside any other if else then it is called nested if else.
Now we check a number is positive, if positive then check it is even or odd.

program:

#include< iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter any number";
cin>>n;
if(n>0)
{
if(n%2==0)
cout<<"positive and even";
else
cout<<"positive and odd";
}
else
cout<<"Number is negative";
return 0;
}


output-

Enter any number
2
positive or even
Enter any number
-23
Number is negative




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!