- Syntax :
variable = (condition) ? expressionTrue : expressionFalse;
- Program :
#include <iostream>
using namespace std;
int main() {
cout <<"\n----------------SHORT HAND IF-ELSE STATEMENT----------------\n";
int a;
cout<<"\nEnter your age :";
cin>>a;
string c = (a < 18) ? "Minor" : "Major";
cout << c;
return 0;
}
- Output :
No comments:
Post a Comment