/*
Conditional Operator or Ternary Operator ( ?: )
=========================================
Syntax:
=======
Expr1 ? Expr2 : Expr3;
If Expr1 = True Then Execute Expr2
If Expr1 = False Then Execute Expr3
*/
#include<iostream.h>
#include<conio.h>
main()
{
int a;
clrscr();
cout<<"\n Enter Number :";
cin>>a;
cout<<"\n Given Number is :"<<(a>0?"Positive":"Negative");
cout<<"\n Given Number is :"<<(a%2==0?"Even":"Odd");
getch();
}
Conditional Operator or Ternary Operator ( ?: )
=========================================
Syntax:
=======
Expr1 ? Expr2 : Expr3;
If Expr1 = True Then Execute Expr2
If Expr1 = False Then Execute Expr3
*/
#include<iostream.h>
#include<conio.h>
main()
{
int a;
clrscr();
cout<<"\n Enter Number :";
cin>>a;
cout<<"\n Given Number is :"<<(a>0?"Positive":"Negative");
cout<<"\n Given Number is :"<<(a%2==0?"Even":"Odd");
getch();
}
No comments:
Post a Comment