Worked Examples · Example 4.4
Q.Write an algorithm to calculate area and perimeter of a rectangle, using both pseudocode and flowchart.
CBSENCERTSubjective· 3mImportance★★★★★est
19% · 7/36 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Read length and breadth, then compute area = length × breadth and perimeter = 2 × (length + breadth) — a straight-line (sequential) algorithm with two process boxes.
The idea. Like the sum-of-two-numbers example, this needs only the sequence construct: two inputs, two formula evaluations, two outputs. The value of writing it out is practising the input → process → output pattern that every flowchart follows.
Pseudocode:
Step 1: INPUT length
Step 2: INPUT breadth
Step 3: area = length * breadth
Step 4: perimeter = 2 * (length + breadth)
Step 5: PRINT area
Step 6: PRINT perimeter
Flowchart (nodes and arrows):
- Start (oval)
- ↓ Input length, breadth (parallelogram)
- ↓ area = length * breadth (rectangle)
- ↓ perimeter = 2 * (length + breadth) (rectangle)
- ↓ Output area, perimeter (parallelogram)
- ↓ Stop (oval)
Python implementation:
length = float(input("Enter length of rectangle: "))
breadth = float(input("Enter breadth of rectangle: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area =", area)
print("Perimeter =", perimeter)
Expected output (sample run):
Enter length of rectangle: 8 …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.