Worked Examples · Example 4.3
Q.Write an algorithm to display the sum of two numbers entered by user, using both pseudocode and flowchart.
Chhattisgarh CgbseTextbookSubjective· 3mImportance★★★★★est
14% · 5/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 →This is a purely sequential algorithm — input two numbers, compute their sum, display it — so both the pseudocode and the flowchart are a straight line with no branches.
The idea. Every algorithm has three possible control structures: sequence, selection, repetition. Adding two user-entered numbers needs only sequence: take inputs, process, produce output. Writing it as pseudocode (language-independent steps) and a flowchart (the same steps as shapes) is the standard way to plan before coding.
Pseudocode:
Step 1: INPUT num1
Step 2: INPUT num2
Step 3: sum = num1 + num2
Step 4: PRINT sum
Flowchart (nodes and arrows):
- Start (oval)
- ↓ Input num1 (parallelogram)
- ↓ Input num2 (parallelogram)
- ↓ sum = num1 + num2 (rectangle — process)
- ↓ Output sum (parallelogram)
- ↓ Stop (oval)
Python implementation:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
sum_of_numbers = num1 + num2
print("Sum =", sum_of_numbers)
Expected output (sample run):
Enter first number: 5 …
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.