This Statement is used when we want to change the normal execution of the program then we need to use control statements or we can say control statements are used to change the flow of programe
it can excute the program which included in { }.they are mainly three type
1 Condition Control Statements (Selective statement)
2 Looping Statements (Iterative Statements)
3 Branching Statements
1. Condition Control Statements - These are used to executed the statement of block of statements according to some condition. it test the condition First if condition is true then it execute the first statement .otherwise execute second condition.There types are given below .
1 if Statement
2 if else Statement
3 if else if Statement
4 Nested if
5 Switch case
it can excute the program which included in { }.they are mainly three type
1 Condition Control Statements (Selective statement)
2 Looping Statements (Iterative Statements)
3 Branching Statements
1. Condition Control Statements - These are used to executed the statement of block of statements according to some condition. it test the condition First if condition is true then it execute the first statement .otherwise execute second condition.There types are given below .
1 if Statement
2 if else Statement
3 if else if Statement
4 Nested if
5 Switch case
if Statement it is the Basic condition control statement in this we can use single condition .the if statement allows a programmer to test the value of conditional expression and to select or reject the execution of the statement of block of statements depending on this value..if the condition is true then statement is executed .
Syntax :
if (Condition )
{
statement 1;
statement 2;
}
if else statement it can performe the two different operation in the programe .if condition is true then execute the first statement ..if condition is wrong then it execute the wrong part ..
Syntax
if (condition )
{
statement 1;
}
else
{
statement 2;
}
if else if if we have more than two conditions then we use if else if statement. in this we can create multiple blocks of statements and statements will execute according to the condition .
Syntax
if (condition )
{
statement ;
}
else if
{
statement ;
}
else
{
wrong statement ;
}
Nested if it means something inside something .it execute if condition which inside to another if condition
syntax
if (condition )
{
if (condition )
{
statement ;
}
else
{
statement ;
}
else
{
statement ;
}
switch statement when we have multiple if statements then we can use switch case statement .The variable used in switch is know as switch variable .the variable also contain the default statement can be of int or char type only .The switch statement can also contain the default statements that will be executed if none of the case is executed defult is optional .
syntax .. switch (expression )
{
case 1:
statement 1;
break;
case 2:
statement 2;
break;
case 3:
statement 3;
break;
default:
worng statement ;
break;
}
Syntax :
if (Condition )
{
statement 1;
statement 2;
}
if else statement it can performe the two different operation in the programe .if condition is true then execute the first statement ..if condition is wrong then it execute the wrong part ..
Syntax
if (condition )
{
statement 1;
}
else
{
statement 2;
}
if else if if we have more than two conditions then we use if else if statement. in this we can create multiple blocks of statements and statements will execute according to the condition .
Syntax
if (condition )
{
statement ;
}
else if
{
statement ;
}
else
{
wrong statement ;
}
Nested if it means something inside something .it execute if condition which inside to another if condition
syntax
if (condition )
{
if (condition )
{
statement ;
}
else
{
statement ;
}
else
{
statement ;
}
switch statement when we have multiple if statements then we can use switch case statement .The variable used in switch is know as switch variable .the variable also contain the default statement can be of int or char type only .The switch statement can also contain the default statements that will be executed if none of the case is executed defult is optional .
syntax .. switch (expression )
{
case 1:
statement 1;
break;
case 2:
statement 2;
break;
case 3:
statement 3;
break;
default:
worng statement ;
break;
}









0 comments:
Post a Comment