Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Input/Output statements
  5. Decision making statement...
  6. Nested if statement

Nested if statement

Nested if statement

Syntax

if(expression)
{
     Statement 1
     if(expression)
     {
Statement 2
     }
}

Flowchart

Example

#include<stdio.h>
int main()
{
	int a=100;
	int b=200;
	if(a==100)
	{
		if(b==200)
		{
			printf("a=%d,b=%d\n",a,b);
		}
	}
	printf("a=%d,b=%d\n",a,b);
	return 0;
}

Output

a=100,b=200
a=100,b=200

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments