Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Dashboard

Branching in #C : Nested If-else and their uses in programs (part-3)-(module-19)

In this section we will continue our discussion on the next topic... that is part 3(branching) of C. The control statements and its many applications in writing a program using the concepts of loops and branching, different types of branching like if statement, if-else statements, nested if else statements etc.

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180
This is the 19th module on learning C with us. Earlier we discussed on the basic introduction and structure of C, preprocessor it's features, intermediate and executable codes. compilation and execution process of a C program. And keywords and identifiers, data types, variables and constants, scope of variables, operators and expressions in C. Type casting in #C. Introduction to input and output functions and reading a character in #C. Unformatted and formatted input functions.
 In this section we will continue our discussion on the next topic... that is part 3 (branching) of C. The nested if-else branching, different types of branching like if statement, if-else statements, nested if else statements etc. 
For part 1 and part 2 you may refer to the below given link : 
part-1 if
Part-2 if-else 
Nested if-else statement (Part B) :- 
Format :  
if(condition)                                                          { if(condition)                                                           { statement 1; }                                           else                                                                           { statement 2; }                                           }                                                                     else                                                                         { if(condition)                                                          { statement 1; }                                           else                                                                           { statement 2; }                                           } 
 In the above type first the condition checks, if the condition is true then it enters into sub condition and executes the statement of true part of the sub condition, if the condition is true the statements are executed, if the condition is fails then it enters into the else block, in else there is another if statement, it also checks the condition in else block and if the condition is true executes the true part or else follow the same process for the rest.
 example : 
main() 
{ int a,b,c; 
 printf("enter three numbers"); 
 scanf("%d%d%d",&a,&b,&c);
 if(a==b) 
      { if(b==c) 
          printf("all numbers are same"); 
      }
else 
    printf("all the numbers are different"); 
}
For part A on nested if-else structure please refer here ? : 
Nested if-else structure (Part A) 
In next module we will continue our discussions on the next topic on switch statement. For more information regarding #C please be updated with us only on Www.newsandstory.com as we provide all the information on all the topics covered in #C.   
CONTINUE READING
Nested if-else
if
if-else
condition
statements
Programming
learning
coding
technology
Dalpat I
Content writer