In C Programming Language, we can use Nested if Statement when we want to test multiple conditions.

Syntax of Nested if statement

if(condition)
{
if(condition)
{
Statement;
}
}

Simple Program of Nested if statement in C

find the greatest of three numbers in C

#include <stdio.h>
#include<conio.h>;
void main(){
{
int x,y,z;
clrscr();
printf(“Enter three Number:n”);
scanf(“%d%d%d”,&x,&y,&z);
if(x>y)
{
if(x>z)
{
printf(“X is greatest Number:%d”,x);
}
else
{
printf(“Z is greatest Number:%d”,z);
}
}
else
{
if(y>z)
{
printf(“Y is greatest Number: %d”,y);
}
else
{
printf(“Z is greatest Numebr %d”,z);
}
}
getch();
}

Output
Enter three Number: 10 20 4
B is greatest Number 20

This article is written by our awesome writer
Comments to: Nested 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