PseudoCode if else Loops special cases and nested
- Slides: 13
Pseudo-Code if else /Loops special cases and nested loops Class Activity ICS B Spring 2015 Anham Liaqat
if else /Loops special cases
Case#1 Pseudocode: Count = 0 WHILE Count NOT equals t 0 zero OUTPUT Count= Count +1 END WHILE Loop that will never true
Case#2 Pseudocode: Count = 1 WHILE Count > 0 Count= Count +1 END WHILE Infinite Loop that never terminates
Case#3 Pseudocode: Count = 1 IF Count = 1 OUTPUT Count IF Count NOT 1 Count +1 OUTPUT Count +1 ELSE Count +1 OUTPUT Count +1 There is a dangling ELSE
Case#4 Problem : take input Count and Output Count only when count > 0 and count < 10 Pseudocode: INPUT Count IF Count < 10 OUTPUTIFZCount > 0 OUTPUT Count END IF AND Conditions can write using nested if
Case#5 Problem : take input Count and Output Count only when count > 10 or count equals to 5 Pseudocode: INPUT Count IF Count > 10 OUTPUT Count ELSE OUTPUT Z IF Count equals to 5 OUTPUT Count END IF OR Conditions can write using nested if else
Case#6 Problem : take input Count and Output Count only when count NOT equals to 5 Pseudocode: INPUT Count IF Count equals to 5 ELSE Count OUTPUT Z END IF NOT Conditions can write using if else
Nested Loops
Pseudocode: Row= 1 WHILE Row < = 5 =1 Count = Count 1 WHILE Count < = 5 OUTPUT “ * ” Count = Count +1 END WHILE OUTPUT new line Row = Row + 1 END WHILE Exercise 1 What is output of this program ***** *****
Exercise 2 Using previous exercise modify the output * ** *****
Exercise 3 �Write a loop to print this fencepost pattern. Such fencepost loops can be created by placing one post (i. e. |) outside your loop, and then alternating between wires (i. e. ==) and posts inside the loop. �If user input 4, your output |==|==| �If user input 5, your output |==|==|==|
Exercise 4 �Calculates the series 1 + r 2 +. . . + rn n is given by user.
- Nested loops pseudocode
- While loops and if-else structures
- Matlab nested classes
- Dame meaning in baa black sheep
- Perulangan python
- Nested loops python
- Array bersarang
- Complexity of nested for loops
- Loops
- Hints oracle ejemplos
- Space complexity vs time complexity
- Nested loops storytelling
- Types of array in c
- Nested loops java