- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use ‘else if ladder’ conditional statement is C language?
Else − if the ladder is the most general way of writing a multi-way decision.
The syntax for else if the ladder is as follows −
if (condition1) stmt1; else if (condition2) stmt2; - - - - - - - - - - else if (condition n) stmtn; else stmt x;
Flowchart
Refer the flowchart given below −
Example
Following is the C program to execute Else If Ladder conditional statement −
#include<stdio.h> void main (){ int a,b,c,d; printf("Enter the values of a,b,c,d: "); scanf("%d%d%d%d",&a,&b,&c,&d); if(a>b){ printf("%d is the largest",a); } else if(b>c){ printf("%d is the largest",b); } else if(c>d){ printf("%d is the largest",c); } else{ printf("%d is the largest",d); } }
Output
When the above program is executed, it produces the following result −
Enter the values of a,b,c,d: 2 3 4 5 5 is the largest
- Related Articles
- Explain else-if ladder statement in C language
- Java if-else-if ladder statement
- Explain if-else statement in C language
- How to use else conditional statement with for loop in python?
- Explain Nested if-else statement in C language
- What is the ‘if...else if...else’ statement in Java and how to use it?
- What is the ‘if else’ statement in Java and how to use it?
- Using else conditional statement with for loop in python
- How to use if...else statement at the command line in Python?
- How to use else statement with Loops in Python?
- Java if-else statement
- What is if...else if... statement in JavaScript?
- IF ELSE statement in a MySQL Statement?
- How to indent an if...else statement in Python?
- How to use #if..#elif…#else…#endif directives in C#?

Advertisements