Chapter 2 Introduction to C part 3 Decision if case
Chapter 2 Introduction to C part 3 Decision if case
A Central University
CS-101:Fundamentals
of Computing
Mr. Hannan Mansoor
Department of Computer Engineering,
FET, JMI
2 Unit 2:
INTRODUCTION TO C PROGRAMMING
Algorithms, decision controls,
flow chart, if and else, conditional operator
The keyword “if” tells the compiler that the code followed after it is a decision
control instruction.
if( expression/condition)
execute the statement;
if condition is “false”.
Condition
if condition is “true”.
Conditional
Code/statement
if condition is “false”.
Condition
if condition is “true”.
Conditional else
Code/statement code
if(condition 1 )
Conditional statement 1
else if(condition 2)
Conditional statement 2
else if(condition 3)
Conditional statement 3
else
statement 4
Switch statement in C
Thank You