Nested if else Nested if else By B. Bhaskar sethupathi
Nested IF ELSE Nested IF functions, meaning one IF function inside of another , allows you to test multiple criteria and increases the number of possible outcomes. Using “If…else Statement” Within Another “If…else Statement” Is Called ‘Nested If Statement’. “Nested If Statements” Is Mainly Used To Test Multiple Conditions. It is called nested conditional branching.
Nested if else Structure if ( test_condition ) { if ( test_condition ) { statement-block; } else { statement-block; } } else { statement-block; } statement-x; Nested if else
Flowchart for nested if else:
#include < stdio.h > int main () { int a; printf (“Enter no:"); scanf ("%d“, &a); if( a>=0) { if( a ==0 ) { printf (“The no is zero" ); } else { printf (“Positive no"); } } else { printf (“Negative no"); } } Program to print positive no or negative no or zero using nested if else
Output: Enter no: 0 The no is zero
program for whether given numbers are equal #include < stdio.h > int main() { int a, b, c; scanf ("%d %d %d", &a, &b, &c); if (a == b) { if (a == c) { printf ("Yes"); } else { printf ("No"); } } else { printf ("No"); } Return 0; }