If Statement In C Programming

Posted on

If Assertion

if-then Assertion

 

if-then is most simple assertion of Determination making assertion. It tells to program to execute a sure a part of code provided that explicit situation or take a look at is true.

Syntax

if(situation){....................}

Instance

#embrace#embracevoid important(){int a=10;if(a<=10){printf("a is lower than 10");}getch();}

Output

a is lower than 10

if statement - If Statement In C Programming

  • Setting up the physique of “if” assertion is all the time non-compulsory, Create the physique after we are having a number of statements.
  • For a single assertion, it’s not required to specify the physique.
  • If the physique shouldn’t be specified, then mechanically situation half can be terminated with subsequent semicolon ( ; ).

else

It’s a key phrase, by utilizing this key phrase we are able to create a various block for “if” half. Utilizing else is all the time non-compulsory i.e, it is suggested to make use of after we are having alternate block of situation.

In any program amongst if and else just one block can be executed. When if situation is fake then else half can be executed, if half is executed then mechanically else half can be ignored.

Syntax

if(situation){....................}else{................}

Instance

#embrace#embracevoid important(){int age=40;if(age<18){printf("you might be youngster");}else{printf("you might be younger");}getch();}

Output

you might be younger