Lecture# 21 Nested if Statement in C++ | C++ Programming Tutorials in Urdu

Write a program to check a number is positive or negative and then find it is even or odd

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

Watch video for more information

Leave a Reply