c++ decision making

switch statement

int zaki;
cin>>zaki;
switch(zaki)
{
case 1:
cout<<"This is 1";
break;

case 2:
cout<<"This is 2";

case 3:

default:
cout<<"Hello ! :D"<<endl;

}

 

IF statement

if(a==10){
statement;
}

 

if..else Statements

if(a==10){
cout<<"dosh :D";
}else{
cout<<"Print"<<;
}

 

 

if…else…if statements

if(a==10){
cout<<"dosh :D";
}else if{
cout<<"Print"<<;
}else{
"Yeppi";
}

 

Ternary Operator

(a<b)?true:false;

example:

#include<iostream>
using namespace std;

int main()
{
int x,a=10;
x=(a<10)?30:40;
cout<<x;
return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.