Skip to content
Worked Examples · Example 4.1

Q.Write an algorithm to find the square of a number.

CBSENCERTSubjective· 2mImportance★★★★★est
3% · 1/36 Questions
🔒 Locked · start free trial →

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 →

Input the number, multiply it by itself, output the product — the minimal three-step input–process–output algorithm.

The idea. Squaring means multiplying a number by itself, so the whole algorithm is one arithmetic step wrapped in input and output. It is the cleanest illustration of the universal algorithm skeleton: input → process → output.

Algorithm

SQUARE_OF_NUMBER
Step 1: INPUT num
Step 2: COMPUTE square = num * num
Step 3: PRINT "Square of the number =", square
END

Flowchart in words: Start (rounded rectangle) → Input num (parallelogram) → square = num × num (rectangle) → Output square (parallelogram) → Stop (rounded rectangle).

Python verification

num = float(input("Enter a number: "))
square = num * num
print("Square of", num, "is", square)

Sample runs

Enter a number: 7
Square of 7.0 is 49.0

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.