شرح if condition
شرح if condition
/*
Control Flow
- If Condition Introduction
Syntax
if (Condition Is True)
// Do Something
*/
#include <iostream>
int main()
return 0;
}
31#Control Flow – If, Else If, Else
/*
Control Flow
Syntax
if (Condition Is True)
// Do Something
*/
#include <iostream>
int main()
int rank = 4;
{
cout << "Welcome Your Age Is Ok\n";
else
return 0;
}
32#Control Flow – Nested If Conditions
/*
Control Flow
- Nested If Conditions
*/
#include <iostream>
int main()
return 0;
}
33#Control Flow – Ternary Conditional Operator
/*
Control Flow
- Ternary Operator
Syntax
*/
#include <iostream>
int main()
else
}
cout << (age >= 18 ? "Age Is OK\n" : "Age Is Not OK\n");
return 0;
}
34#Control Flow – Nested Ternary Operator
/*
Control Flow
Syntax
*/
#include <iostream>
int main()
else
{
else
cout << (age >= 18 ? "OK\n" : (points >= 500 ? "OK P\n" : "No P\n"));
else
return 0;
}
Control Flow – Switch, Case
/*
Control Flow
- Switch
*/
#include <iostream>
int main()
int day;
if (day == 1)
else if (day == 2)
else if (day == 3)
{
else
switch (day)
case 1:
case 2:
break;
case 3:
break;
default:
return 0;
}
Switch Training – Create Three Application
/*
Control Flow
- Switch Trainings
*/
#include <iostream>
int main()
int num;
switch (num)
case 100:
case 110:
case 120:
break;
case 200:
break;
case 300:
break;
case 400:
break;
default:
int years;
switch (years)
{
case 1:
discount = 20;
break;
case 2:
discount = 40;
break;
case 3:
discount = 80;
break;
cout << "The Price Is " << price - discount << "\n";
if (op == 1)
else if (op == 2)
else if (op == 3)
else if (op == 4)
else
switch (op)
{
case 1:
cout << n1 << " + " << n2 << " = " << n1 + n2 << "\n";
break;
case 2:
cout << n1 << " - " << n2 << " = " << n1 - n2 << "\n";
break;
case 3:
cout << n1 << " / " << n2 << " = " << n1 / n2 << "\n";
break;
case 4:
cout << n1 << " * " << n2 << " = " << n1 * n2 << "\n";
break;
default:
return 0;