If Else Statement


In C Programming language,we use if else statements to perform both true & false statement.


Syntax of if-else statement

if(condition){

True statement;

}else{

False statement;

}


Example of if else statement in c

Check a Number Positive or Negative


#include <stdio.h>

#include<conio.h>

void main(){

int num;

clrscr();

printf(“Enter Your Age:\n”);

scanf(“%d”,&num);

if(num>=18){

printf(“Congrats You are Eligible For Vote");

}else{

printf(“Sorry, You are not Eligible For Vote Yet");

}

getch();

}


Output of the above program:
Enter a Digit 18 : Congrats You are Eligible For Vote

Enter a Digit 16: Sorry, You are not Eligible For Vote