If Else Statement In C Language Ppt
C programming conditional operator is also known as a ternary operator. It takes three operands. Conditional operator is closely related with if..else statement.
Control structures are compound statements like if/then/else, while, for, and do.while that control how or whether their component statements are executed. Simple statements. The simplest kind of statement in C is an expression (followed by a semicolon, the terminator for all simple statements). Its value is computed and discarded. 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.
Syntax of C programming conditional operator
If the condition is true then expression1 is executed else expression2 is executed.
For example:
Here, puts
statement contains as its second argument a conditional expression which evaluates to the string 'x is greater'
if the condition x > y
is true and 'y is greater'
if the condition is false.It can also be done as
It can also be done as
Here, if x > y
then puts('x is greater')
else puts('y is greater')
.
The output of both expressions is same.
Example: C program to check whether the student is pass or fail using conditional operator
Output
Explanation
![Ppt Ppt](https://s3-ap-southeast-1.amazonaws.com/mpt15awshkbkt1/resources_conversion_files/presentationcontrolstatements1442948285140676-27.jpg)
If Else Statement C++ 11
The program checks the condition mark >=40
, if it is true 'Passed'
is printed else 'Failed'
.
The above program can be simply done with the help of if...else
statement.
![If statements in c++ pdf If statements in c++ pdf](https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2018/11/Python-Conditional-Statements.png)
![If else statement in c language ppt format If else statement in c language ppt format](https://cdn.programiz.com/sites/tutorial2program/files/how-if-else-works-c-programming.jpg)
Programming In C Language
Output
![](https://cdn-ak.f.st-hatena.com/images/fotolife/r/ruriatunifoefec/20200910/20200910011329.png)