/* In this vedio we will learn control flow which consists of two concepts:
1. Branching
2. Loopoing
these are fundamental for making complex programs.
1. Branching:
a) If statements
b) Switch statements
2. Looping techniques:
a)while statement
b)for loop
c) do while loop
1.a) If statement:
if(expression) //if true will execute the code below.
{
//code
}
elseif(expre)
{
//do this
}
elseif(expre)
{
//do this
}
//in the end we have single else statement:
else
{
//finally do this
}
this is like branching: we go straght in code from top to bottom, enter
if statement, then else if and then else, so it is branching structure.
1b) Switch statement:
switch(age) //switch can only take integer cases, that reduces usefulness a lot. moreover we can't take values for conditions like age<20,
{
case 24:
//code;
break; //if we don't put break statement then code will follow the below case.
case 26:
//code;
break;
default:
//cout<<"this is default if age is neighter 24 and 26";
break;
}
switch statement is much more limited in comparision to if statement. we can always
write any switch code with if statements.
*/
#include<iostream>
int main()
{
enum class season{winter,summer,spring,fall};
season now=season::winter;
switch(now)
{
case season::winter:
std::cout<<"take care from winter"<<std::endl;
break;
case season::summer:
std::cout<<" stay away from sun"<<std::endl;
break;
case season::spring:
break;
case season::fall:
break;
}
return 0;
}