• Call Us: +91 9437911966
  • Email Us: info@studentstutorial.com
  • Home
  • C Examples
  • Server Side
    • PHP
    • Java
    • CodeIgniter
    • Laravel
    • JSP
    • JDBC
  • Frontend
    • HTML
    • CSS
    • Javascript
    • jQuery
    • AJAX
    • FPDF
    • TCPDF
  • APP & DB
    • Android
    • Cordova
    • SQL
    • Oracle
  • Project
C Tutorial C Introduction C Characteristic C Comments C Operator C Assign Operator C Arithmetic Oper.. C Logical Operator C Modulus Operator C Variable C Initialise Variable C Print F C Translators C Programming C Control Flow C If Else Statement C Nested If Else C Loops C While Loops C For Loops C Do While C Nested Loops

C Nested If-Else

  • Students Tutorial
  • 08 jun 2020
   

It is a procedure of constructing a condition within an existing conditional block.

In C programming language, it is possible to place up to 255 nested blocks.

Syntax:

Assignment 1;
If condition

{

	Block 1;

  }

 Else

 {

	If condition 2

{

Block 2;

}

Else

{

If condition 3

{

   Block 3;

}

Else

{

  Block 4;

}

}
	

According to syntax, semicolons must be required at the end of the body.

*According to syntax, if condition 1 is true then block 1 is executed, if it is false then control will pass to the else part.

* Within the else part if condition 2 is true then block 2 will execute, if it is false then control will pass to nested else.

* Within the nested else, if condition 3 is true then block 3 will execute, if it is false then block 4 will be executed.

* when we are working with nested if else at any point of time, only one block will be executed or can be executed.

*Nested concepts can be applied for if part and else part also.

*If we are applying the nested concepts to if part then it is called nested if- else, if we are applying to else part, then it is called else if ladder.

Prog:   a       b        c        d

Syntax:

min

Void main ( )

{

Int a, b, c, d, min;

Clrscr ( );

Print f (“Enter 4 values :”);

Scan f (“%d %d %d %d”, &a, &b, &c, &d);

If (a<b && a<c && a<d)

{

   Min =a;

 }

Else

{

 If (b<c && b<d)

  {

	Min =b;

   }

   Else

   {

  If (c< d)

	 Min =c;

  Else

	   Min =d;

}

 }

   Print f (“min value is: %d”, min);

	Getch ( );

}

Student Tutorial is a online tutorial for web design and development. Here you can find easy example and explanation for each tutorial.
Copyright © 2016-2025 Student Tutorial

Server Side

  • PHP
  • Java
  • CodeIgniter
  • Laravel
  • JSP
  • JDBC

Frontend

  • HTML
  • CSS
  • Javascript
  • jQuery
  • AJAX
  • FPDF

App & Database

  • Android
  • Cordova
  • SQL
  • Oracle