Dicision Making : if statement Part 2
Structure of if statement
The basic structure of it statement is given bellow :
if(conditional expression) { statement 1 ; statement 2 ; ------------------------- statement n ; } statement x ; |
Here we put the any condition inside the first bracket and the second bracket is the block of the if statement, here we write the other expression which is depended to the if condition.
Now we write the a program :
#include<stdio.h> void main() { int a=5, b=10; if(a<b) {printf(“a is less then b”);} if(a>b) {printf(“a is greater then b”);} } Output : a is less then b |
Here is the first condition is (a < b). If the value of ‘a’ is less then ‘b’, if the condition is true then the statement of printf() will be execute. And if (a>b) condition is true then the printf statement which is situated in the block.
Dear learner, i hope you understand if statement and it operation.
Written by “Shojib”
No comments:
Post a Comment