Software & Finance

Turbo C - ELSE IF ladder

Here is an example for else if ladder in C Programming Language. Else if ladder means, an simple if statement occurs with in the else part of simple if else statement.


if statement evaluates the condition inside the paranthesis and if it is true, then it executes one line followed by if statement or the sequence of steps bound of { }.


if statement can be combined with else part which is explained in if else statement.


Nested if statement is explained with finding the biggest of 3 numbers example.


Else if ladder is explained with an example given below:

Source Code

#include <stdio.h>


void main()


   int choice;


   printf("[1] Add\n");

   printf("[2] Edit\n");

   printf("[3] Delete\n");

   printf("[4] View\n");

   printf("[5] Exit\n");


   printf("Enter your choice: ");


   scanf("%d", &choice);


   if(choice == 1)

      printf("Add option selected");

   else if(choice == 2)

      printf("Edit option selected");

   else if(choice == 3)

      printf("Delete option selected");

   else if(choice == 4)

      printf("View option selected");

   else if(choice == 5)

      printf("Exit option selected");


      printf("Invalid option selected");




[1] Add
[2] Edit
[3] Delete
[4] View
[5] Exit
Enter your choice: 4


View option selected