The conditional expressions are mainly used for decision making...... There are various types of control statements...... The following statements are used to perform the task of the conditional operations ........
(1) If statement
(2) If-else statement
(3) switch-case statement
3.1.1..... if statement
The if statement is used to express conditional expressions . If the given condition is true then it will execute the statement ; otherwise it will execute optional statements....
The braces { and } are used to group declaration and statements into a compound statement or a block... These compound statements or blocks are always considered as a single statements. The basic simple structure of the if statement is shown below :
if(expression)
{
statement;
statement;
-----------;
-----------;
}
The expression is evaluated and if it is 'true' , the statement following the if is executed . In case the given structure is 'false' , the statement is skipped and execution continues with next statement.....
For example ,
a=20;
b=10;
if(a>b)
{
cout<<"largest value=" '<<'a;
}
If the given condition is satisfied computer will print the message "largest value=20"
Thanks for the day, rest of the topic in my next posts
Thursday, July 3
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment