Lecture# 17 if-else-if statement explained with example| C++ Programming Tutorials in Urdu

If-else-if

  • When we have more than one condition

Write a program to find a number is positive,negative or zero

include"iostream"
using namespace std;
main()
{
int n;
cout<<"Enter a number = "; cin>>n;
if(n>0)
{
cout<<"Number is Positive";
}
else if(n<0)
{
cout<<"Number is Negative";
}
else
cout<<"Number is zero";
}

Watch video for more information

Leave a Reply