If Statement

C conditional statement allows us to create a decision in C programming language.

We know very well that no task would take place without any condition than how can we use this conditional term in programming languages.

There are many way to use conditional statement in c.

  • If statement
  • If else statement
  • Nested If statement
  • If else-if ladder statement
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: %dn”, c);
}
getch();
}

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

This article is written by our awesome writer
Comments to: If Statement in C Programming Language

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Explore Tutorials By Categories

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password