Lecture SP08 Decision Making and Branching 1
Lecture SP08 Decision Making and Branching 1
Structured Programming
Lecture 8
Decision Making and Branching in C (1)
Prepared by________________________________
Md. Mijanur Rahman, Prof. Dr.
Dept. of Computer Science and Engineering
Jatiya Kabi Kazi Nazrul Islam University, Bangladesh
www.mijanrahman.com
Contents
DECISION MAKING AND BRANCHING IN C
• Conditional Control Structures
• Selection Statements
• if statement
• if..else statements
• nested if statements
• if-else-if ladder
• switch statements
• Jump Statements:
• break
• continue
• goto
• return
• Here, the condition after evaluation will be either true or false. C if statement accepts boolean
values – if the value is true then it will execute the block of statements below it otherwise not.
If we do not provide the curly braces ‘{‘ and ‘}’ after if(condition) then by default if statement
will consider the first immediately below statement to be inside its block.
Flowchart of IF statement
Decision Making and Branching in C 7
If Statement in C
• Example:
1. // C program to illustrate If statement
2. #include <stdio.h>
3.
4. int main() {
5. int i = 10;
6.
7. if (i > 15)
8. {
9. printf("10 is less than 15");
10. }
11.
12. printf("I am Not in if");
13. }