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 A) :-

format :
                       { statement 1; }
                else
                       { if(condition)
                                { statement 1; }
                         else
                                { statement 2; }
                         }
In the above type first the condition checks, if the condition is true then it executes the statement of true part, 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()
{ float avg;
  printf("enter your average marks");
  scanf("%f",&avg);
  if(avg>=80)
       printf("you got distinction");
 else if(avg>=70)
       printf("you got high first class");
 else if(avg>=60)
       printf("you got first class");
 else if(avg>=50)
       printf("you got second class");
 else if(avg>=35)
       printf("you got third class");
  else
       printf("failed");
}
For part B on nested if-else structure please refer here ? :
Nested if-else structure (Part B)
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
if
if-else
#C
conditional sentences
loops
branching
nested structures
programming
coding
learning
technology
Dalpat I
Content writer