Getting Started With C

else if ladder statements

Syntax:

if (condition1) {
// Code to execute if condition1 is true
} else if (condition2) {
// Code to execute if condition2 is true
} else if (condition3) {
// Code to execute if condition3 is true
}
// Add more else if blocks as needed
else {
// Code to execute if none of the conditions are true
}

Explanation:

Sample code:

Program.c

output:

output.c

Resources :

Featured
Special title treatment

With supporting text below as a natural lead-in to additional content.

Q1. If you have to make decision based on multiple choices, which of the following is best suited?

Q2. What will be the output of following program ?

                          #include 
                            int main()
                            {
                                int a=10;
                                if(10L == a)
                                    printf("10L");
                                else if(10==a)
                                    printf("10");
                                else
                                    printf("0");
                                return 0;
                            }
                            
                          }