nested if.pptx

654 views 9 slides Apr 10, 2023
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

C Programming


Slide Content

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; }

OUTPUT: 1 1 1
Yes
Tags