Control Statement
Control Statement s Are Used To Control The Flow Of Execution. There Are Three Types Of Control Statements In C Language. If Statement If Else If Else Ladder
1.If Statement -
It Is Used To Perform Operations Based On The Condition. Syntax If(condition) { //code to be executed; } Example Write A Program To Print Given Number Is Even Or Odd. #Include #include voidmain() { int i; clrscr(); printf("Enter Any Integer"); scanf("%d",&i); if (i%2===0) { printf("%d is an even number",i); } getch(); }  Result Enter Any Integer 10 10 Is An Even Number Â
If Else Statement
By Using If Else Statement We Can Perform The Operations Either Condition Is True Or False. Syntax If(Expression) { // Code To Be Executed If Condition Is True: } Else { //Code To Be Executed If Condition Is False; } Example Write A Program To Print The Number Is Given Number Is Even Or Odd. #Include #include voidmain() { int i; clrscr(); printf("Enter Any Integer",i); scanf("%d",&i); If(i%2==0) { printf("%d is an even number",i); } else { printf("%d is an odd number",i); } getch(); } Result Enter An Integer 6 6 is an even number Â
If Else Ladder
It Is Used To Execute One Code From Multiple Conditions. Syntax if(condition 1) { //code to be executed if condition 1 is true; } else if(condition 2) //code to be executed if condition 2 is true; } else if(condition 3) //code to be executed if condition 3 is true; } else { //code to be executed if condition 4 is false: } Â Example #include #include voidmain() { int i; clrscr(); printf("Enter Any Integer From 1 to 8 : "); scanf("%d",&i); if(i==2) { printf("%d Is An Even Number",i); } elseif(i==4) printf("%d is An Even Number",i); } elseif(i==6) { printf("%d Is An Even Number",i); } elseif(i==8) { printf("%d Is An Even Number",i); } else { printf("%d Is An Odd Number",i); } getch(); } Result Enter Any Integer From 1 to 8 : 7 7 Is An Odd Number. Â Read the full article













