I don't really get your point, it is unlikely that both then-statement and else-statement should be executed. I daresay it is impossible.
Try me:
printf ("before if\n");
if (1) printf ("condition is true (non zero)\n");
else printf ("condition is false (zero)\n");
printf ("after if\n");
there are two types of selection statements in c-language they are if-else and switch case.these two are known as selection statements,because their syntax is like this,if-else syntax:-if(condition){statements}else{statement}in the abow syntax it contains two blocks first one is if and second one is else in 'if' it fills with required condition if the condition is satisfied then it execute the if block,whether it is false it execute the else statements.switch case syntax:-switch(condition){case.1:statements;case.2:statements;case.3:statements;...case.n:statements;default:statement;}in abow switch case we can select any case and execute,in this selection statement gives the fiexibulity to the user.it contains default statement it shows the wrong selection in these cases.examples programs to these statements:-1.biggest of two numbers program?main(){int a,b,c;printf("enter a,b values");scanf(&a);scanf(&b);scanf(&c);if(a>b){printf("a is big");}else{printf("b is big");}}out put:-enter a,b values 8,5a is bigenter a,b values 3,9b is big2.perform arithmetic operation intwo numbers?main(){int a,b,c,d;printf("enter a,b values");scanf(&a);scanf(&b);scanf(&c);printf("enter your choice"&c);switch(c){case.1:d=a+b;printf("d value is"&d);case.2:d=a-b;printf("d value is"&d);case.3:d=a*b;printf("d value is"&d);default:printf("wrong selection");}}out put:-enter a,b values 6,5enter your choice 1d=11enter your choice 2d=1enter your choice 3d=30
In C, programs are composed of statements. These statements are terminated with a semi-colon, and are collected in sections known as functions. By convention, a statement should be kept on its own line, as shown in the example below: #include <stdio.h> int main(void) { printf("Hello, World!\n"); return 0; }
A do-while loop is only useful when you want the loop to execute at least once. This is because the conditional expression is evaluated at the end of each iteration, rather than before each each iteration as it is in a for and a while loop.
Selection control statements in C++There are basically two types of control statements in c++ which allows the programmer to modify the regular sequential execution of statements.They are selection and iteration statements. The selection statements allow to choose a set of statements for execution depending on a condition. If statement and switch statement are two statements which allow selection in c++. There is also an operator known as conditional operator which enables selection.If statementSyntax : if (expression or condition){ statement 1;statement 2;}else{ statement 3;statement 4;}The expression or condition is any expression built using relational operators which either yields true or false condition. If no relational operators are used for comparison, then the expression will be evaluated and zero is taken as false and non zero value is taken as true. If the condition is true, statement1 and statement2 is executed otherwise statement 3 and statement 4 is executed. Else part in the if statement is optional. If there is no else part, then the next statement after the if statement is exceuted, if the condition is false. If there is only one statement to be executed in the if part or in the else part, braces can be omitted.Following example program implements the ifstatement.// evenodd.cpp# include # include void main(){int num;cout
The body of the loop.
Reporting Currency
Financial Statements
C language uses only one method for parameter-passing: call by value.
It is always known as a mutation
Asphyxia leads to the condition known as death.
myalgia
hordeolum