Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Programming Fundamentals- Choices & Decisions Programming Fundamentals- Choices & Decisions 4
3
Programming Fundamentals- Choices & Decisions 5 Programming Fundamentals- Choices & Decisions 6
1
03/10/2017
Next Statement
Programming Fundamentals- Choices & Decisions 7 Programming Fundamentals- Choices & Decisions
8
No Condition
If – else statements is true?
Yes
Statement or
Nested if statements Block of Statement or
Statements for Block of
false Statements
Nested if – else statements
Next Statement
The Dangling Else Problem
Programming Fundamentals- Choices & Decisions 9 Programming Fundamentals- Choices & Decisions 10
& ITC and displays the greater of two statement is true can itself be an if statement
The condition in the inner if is only tested if the condition for
the outer if is true
An if that is nested inside another can also contain a nested
if
We can continue nesting ifs, one inside another to whatever
level we want
Programming Fundamentals- Choices & Decisions 11 Programming Fundamentals- Choices & Decisions 12
2
03/10/2017
Programming Fundamentals- Choices & Decisions 13 Programming Fundamentals- Choices & Decisions 14
Programming Fundamentals- Choices & Decisions 15 Programming Fundamentals- Choices & Decisions 16
Exercise 03 Exercise 04
Write a program for the following stateme Write a program for the following stateme
nt nt
Read a character from user and if is an alphab Read a character from user
et or a digit, display the message “you entered if it is an alphabet then check if is in uppercase,
an alphabet” or “you entered a digit” other wis convert it to lowercase
e display “you did not enter an alphabet or digi if it is in lowercase then convert it into uppercas
e.
t”
Finally display the converted alphabet.