If Statement


C conditional statement allows us to create decision in c .We know very well that no one work’s happend without any condition then how can i use this conditional term in programming languages.


There are many way to use conditional statement in c.


  1. If statement

  2. If else statement

  3. Nested If statement

  4. If else-if lader statement

If Statement In C



C conditional statement allows us to create decision in c .We know very well that no one work’s happend without any condition then how can i use this conditional term in programming languages.


Syntax of if statement

if(condition){

stmt;

}


Simple example of if statement in c

Check a Number is positive


#include <stdio.h>

#include<conio.h>

void main(){

int c;

clrscr();

printf(“Enter a Number:\n”);

scanf(“%d”, &c);

if(c>0){

printf(“The Number is Positive: %d\n”, c);

}

getch();

}


Output of the program:
Enter a Number : 2
The Number is Positive: 2