Enter your email id to get regular update free
Your Email

Branching in #C : concept of If and their uses in programs (part 1) (module-19)

In this section we will discuss on the important topic 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.

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 discuss on the most important topic of C that is branching. different types of branching like if statement, if-else statements, nested if else statements etc.
Branching :-
They decide the flow of statements based on evaluation of results of condition. There are many types of branching statement :
1. If satements.
2. If-else statements.
3. Nested If-else statements.

If statement :-
format :     if(condition)
                    {    statement 1;
                          statement 2;   }
The keyword if tells the compiler that what follows is a decision control instruction. The condition following the keyword IF is always enclosed within pair of parentheses. If the condition is true then the statements executed otherwise statements is not executed.

Example :
                  { int a,b;
                     printf("enter two values");
                                printf(" a is greatest");
                     if (a<b)
                                printf(" b is greatest");
                   { int x, y=9;
                    If (x>y)
                         Printf("%d is x",x);
                   If (y>x)
                        Printf("%d is y",y);
In next module we will continue our discussions on the next topic on if else and nested if-else structure. 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.
  For part-2 and part-3 on if else and nested if-else please refer here :
Part 2 ( if-else)
Part 3 (nested if-else)
control statements
nested if-else
Dalpat I
Content writer
Total 811 views