Hello Everyone.Sorry for a Long Delay.
By the way,Now we are going to discuss about Flow of control(of a program).
Flow of Control is a way in which a program is compiled and executed.It can be a bunch of statements Within braces ending with a semicolon or it can be selective or repetitive.

Sequential Flow is as mentioned above a bunch of statements ending with semicolon within braces.For Example:-
int main()
{
statement1;
statement2;
return 0;
}
Selective Flow includes if-else and switch statements which verifies a condition/text expression in order to execute the statements enclosed under it.The usage of if-else and switch statements is Shown in the Example.Example:-
int main()
{
int a,b,c;
cin>>a>>b;
cout<<"\n1.Maximum\n2.Minimum\nEnter your Choice=";
cin>>c;
switch(c)//verify Condition
{ case 1:if(a>b)//text expression-Condition
              cout<<a;
              else 
            cout<<b;
            break;
 case 2:if(a<b)//text expression-Condition
              cout<<a;
              else 
            cout<<b;
            break;
 default:cout<<"\nInvalid Input";
}
return 0;
}
Details of if-else statements will be discussed in the next blog.
Repetitive Flow as the name suggests deals with repetition of code using loops such as for,while and do-while loop.Their detail and usage will be discussed in the upcoming blogs.
Example:-
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)//print all natural numbers till n
cout<<i;
return 0;
}
This is it for now but be ready for the upcoming posts.Next time we will discuss more about the switch case and if-else statements and how to use it.You can ask your queries and doubts in the comments and we will try to answer as fast and appropriate as possible.
Till then Happy Coding.
       



Comments

Popular posts from this blog