Lecture# 24 Conditional Operator with example | C++ Programming Tutorials in Urdu

Conditional Operator

  • It is an alternate of if-else statement
  • It is ternary operator

Write a program that inputs a number and find greater number

include"iostream"
using namespace std;
main()
{
int a,b;
cout<<"Enter first number = "; cin>>a;
cout<<"Enter second number = "; cin>>b;
if(a>b)
{
cout<<"First number is greater ";
}
else
cout<<"Second number is greater";
}

Watch video for more information

Leave a Reply