If Else Statement In C Language Ppt

If Else Statement In C Language Ppt

The IF-ELSE statement where: if is a reserve word in Turbo C expression is relational or boolean expression that evaluates to a TRUE (1) or FALSE (0) value statement1 and statement2 may either be a single Turbo C statement or a block of Turbo C statements. Control Statements Best Explanation in C Language (if else) part 2 Hii friends, Welcome to my channel- Gate4U This YouTube channel will provide you Gate comp.

Output is as: Enter the three Ages of Ram,Sham and Ajay 14 17 19 Ram is Youngest. Ladder if or else if statement When in a complex problem number of condition arise in a sequence, then we can use Ladder-if or else if statement to solve the problem in a simple manner. C Programming Tutorial #06 Conditional Statements: if, if else, cascading if, switch. In 6th lecture of C Programming, we will enter the uncertain world of c.

Essense of condition

When you deal with data, you may want to do a specific processing in case that a it meets a certain condition. For example, the processing depend on whether a person is older than 20 years or not. In order to realize such function, if can be used.

Fundamental structure of if-statement

When condition is satisfied, it can be expressed as true. On the other hand, when it is not satisfied, false can be used. In the case of 'true', value '1' is returned, and value '0' is returned in 'false' case.

In the below, operators are listed, which are often used in conditional equations.

OperatorUsageMeaning
a bif value of a is equal to value of b, 1 will be returned. Otherwise, 0 will be returned
!=a != bif value of a is not equal to value of b, 1 will be returned. Otherwise, 0 will be returned
<a < bif value of a is less than value of b, 1 will be returned. Otherwise, 0 will be returned
>a > bif value of a is more than value of b, 1 will be returned. Otherwise, 0 will be returned
<=a < bif value of a is less than or equal to value of b, 1 will be returned. Otherwise, 0 will be returned
>=a >= bif value of a is more than or equal to value of b, 1 will be returned. Otherwise, 0 will be returned

Examples of if-statement

Multi-conditions (stepwise)

If Else Statement C++ 11

We can set different conditions in a series of processing.

This can be extended to complex conditional equations

Assume that we have a variable 'age' which represents age, and that we want to have conditional equations as follows.

Conditional expressionMeaning
Aolder than 60 years old
Bolder than 20 years old and younger than 60
Othersyounger than 20 years old
Else

In order to realize above condtional expressions, we can write as follows.

If Else Statement In C Language Ppt Download

Multi-conditional equations (simultaneous)

If Else Statement In C Language Ppt Presentation

For example, when we want to consider both age and sex (e.g. 1 for male and 2 for female), below expression is possible

Lessons for C programmingJunichi Susaki, Kyoto University