Practical Programming -L05
Practical Programming -L05
START
SET sum = 0
FOR i FROM 1 TO 50 STEP 2 DO
sum = sum + i
END FOR
PRINT sum
END
5. Practical Exercises
Exercise 2: Write pseudocode to reverse a list of numbers.
START
DEFINE list as an array
SET reversed_list = EMPTY
FOR i FROM LENGTH(list) DOWNTO 1 DO
APPEND list[i] TO reversed_list
END FOR
PRINT reversed_list
END
5. Practical Exercises
For this, you would create a flowchart with the following steps:
1.Start
2.Choose the shape (circle, rectangle, triangle)
3.Based on the shape:
• Circle: Input radius, calculate Area = π * r^2
• Rectangle: Input length and width, calculate Area =
length * width
• Triangle: Input base and height, calculate Area = 0.5 *
base * height
4.Display the result
5.End
5. Practical Exercises
Exercise 4: Flowchart to check the strength of a password
1.Start
2.GET password
3.Check length:
1. If less than 6 characters → Weak
2. If 6-10 characters with letters & numbers → Medium
3. If more than 10 characters with special symbols →
Strong
4.Display password strength
5.End
5. Practical Exercises
Exercise 5: Pseudocode to calculate compound interest
START
READ principal, rate, time
CALCULATE amount = principal * (1 + rate/100)^time
CALCULATE compound_interest = amount - principal
PRINT compound_interest
END
5. Practical Exercises
Exercise 6: Pseudocode to generate the multiplication table for a
given number.
START
READ number
FOR i FROM 1 TO 10 DO
PRINT number, "x", i, "=", number * i
END FOR
END
6. Program Translation Cycle
The program translation cycle consist of the following steps:
Source Code Preprocessing Compilation