C if condition:
Basic syntax of if conditions:
if( //condition ){
work
}
Logic in flow Chart:
How if statement works:
The if conditions statement works ,when our given condition ( ) are true.
When it is false ,then if conditions block will be skipped normally.
Block is the braces { }.
Example:
Question-1: Write a C program .When sum of two number is greater than 10,
print Yes.
Solutions:
here you see we don't use curly braces. Because we needed only single
line of code which will executed
Note: If we don't use {} our code will execute the next one single statement.
And if conditions will not make a block.
Question-2: Write a C program .When sum of two number is greater than 10,
print Yes and print print the sum and minus of to variable.
Solutions:
In here we used curly braces ,so that our code can execute all line. mainly we create a block
Note: it is not necessary to must use else in ours code:
More example from GitHub: Click here
Post a Comment