Skip to main content
Chapter 4 of 11
NCERT Solutions

Introduction to Problem Solving — NCERT Solutions

CBSE · Class 11 · Computer Science

NCERT Solutions for Introduction to Problem Solving, CBSE Class 11 Computer Science: 18 textbook questions solved step by step.

45 questions92 flashcards5 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Introduction to Problem Solving? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

18 Questions Solved · 1 Section

The first 9 solutions are open to read. The other 9 are free with a Super Tutor account.

EXERCISE — Chapter 4: Introduction to Problem Solving

1Write pseudocode that reads two numbers and divide one by another and display the quotient.Show solution

Given: Two numbers are to be read; one is divided by the other and the quotient is displayed.

Concept: Sequential algorithm with input, process, and output steps.

Pseudocode:

BEGIN
  READ num1, num2
  IF num2 ≠ 0 THEN
    quotient ← num1 / num2
    PRINT quotient
  ELSE
    PRINT "Division by zero is not allowed"
  END IF
END

Explanation:

  • num1 and num2 are the two numbers entered by the user.
  • Before dividing, we check that the divisor (num2) is not zero to avoid an undefined operation.
  • The result is stored in quotient and then printed.
2Two friends decide who gets the last slice of a cake by flipping a coin five times. The first person to win three flips wins the cake. An input of 1 means player 1 wins a flip, and a 2 means player 2 wins a flip. Design an algorithm to determine who takes the cake.Show solution

Given: A coin is flipped up to 5 times. Input is 1 (Player 1 wins flip) or 2 (Player 2 wins flip). The first player to win 3 flips takes the cake.

Concept: Iterative algorithm with conditional checks.

Algorithm:

BEGIN
  SET count1 ← 0   // wins for Player 1
  SET count2 ← 0   // wins for Player 2
  SET flip   ← 0   // flip counter

  WHILE (flip < 5) AND (count1 < 3) AND (count2 < 3) DO
    READ result        // 1 or 2
    IF result = 1 THEN
      count1 ← count1 + 1
    ELSE IF result = 2 THEN
      count2 ← count2 + 1
    END IF
    flip ← flip + 1
  END WHILE

  IF count1 = 3 THEN
    PRINT "Player 1 wins the cake"
  ELSE IF count2 = 3 THEN
    PRINT "Player 2 wins the cake"
  ELSE
    IF count1 > count2 THEN
      PRINT "Player 1 wins the cake"
    ELSE IF count2 > count1 THEN
      PRINT "Player 2 wins the cake"
    ELSE
      PRINT "It is a tie — flip again"
    END IF
  END IF
END

Explanation:

  • The loop runs at most 5 times but exits early as soon as either player reaches 3 wins.
  • After the loop, the player with 3 wins is declared the winner; if neither reached 3 in 5 flips, the player with more wins takes the cake.
3Write the pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and 25).Show solution

Given: Print all multiples of 5 from 10 to 25 (inclusive).

Concept: Iterative algorithm using a loop that increments by 5.

Pseudocode:

BEGIN
  SET num ← 10
  WHILE num <= 25 DO
    PRINT num
    num ← num + 5
  END WHILE
END

Output: 10, 15, 20, 25

Explanation:

  • The variable num starts at 10 (the first multiple of 5 in the range).
  • Each iteration prints the current value and then adds 5.
  • The loop stops after printing 25 because the next value (30) exceeds 25.
4Give an example of a loop that is to be executed a certain number of times.Show solution

Concept: A count-controlled loop (also called a definite loop) executes a fixed, predetermined number of times.

Example — Print "Hello" 5 times:

BEGIN
  SET count ← 1
  WHILE count <= 5 DO
    PRINT "Hello"
    count ← count + 1
  END WHILE
END

Explanation:

  • The variable count acts as a counter.
  • The loop body executes exactly 5 times (when count = 1, 2, 3, 4, 5).
  • When count becomes 6, the condition count <= 5 is false and the loop terminates.
  • This is a classic example of a loop executed a certain (fixed) number of times.
5Suppose you are collecting money for something. You need ₹200 in all. You ask your parents, uncles and aunts as well as grandparents. Different people may give either ₹10, ₹20 or even ₹50. You will collect till the total becomes 200. Write the algorithm.Show solution

Given: Collect money from various people (each giving ₹10, ₹20, or ₹50) until the total reaches ₹200.

Concept: Iterative algorithm with an accumulator and a termination condition.

Algorithm:

BEGIN
  SET total ← 0

  WHILE total < 200 DO
    PRINT "Enter amount received (10, 20, or 50): "
    READ amount
    IF (amount = 10) OR (amount = 20) OR (amount = 50) THEN
      total ← total + amount
      PRINT "Total collected so far: ", total
    ELSE
      PRINT "Invalid amount. Please enter 10, 20, or 50."
    END IF
  END WHILE

  PRINT "Target of ₹200 reached! Total collected = ", total
END

Explanation:

  • total accumulates the money collected.
  • Each time a valid amount is entered, it is added to total.
  • The loop continues until total is at least ₹200.
  • Invalid inputs are rejected with an error message.
6Write the pseudocode to print the bill depending upon the price and quantity of an item. Also print Bill GST, which is the bill after adding 5% of tax in the total bill.Show solution

Given: Price and quantity of an item are known. Calculate the total bill and then add 5% GST to get the final bill.

Formula:
Total Bill=Price×Quantity\text{Total Bill} = \text{Price} \times \text{Quantity}
GST Amount=Total Bill×5100\text{GST Amount} = \text{Total Bill} \times \frac{5}{100}
Bill with GST=Total Bill+GST Amount\text{Bill with GST} = \text{Total Bill} + \text{GST Amount}

Pseudocode:

BEGIN
  READ price, quantity
  total_bill   ← price × quantity
  gst_amount   ← total_bill × 5 / 100
  bill_with_gst ← total_bill + gst_amount

  PRINT "Total Bill (before GST) = ", total_bill
  PRINT "GST (5%)               = ", gst_amount
  PRINT "Total Bill (after GST) = ", bill_with_gst
END

Example: If price = ₹100 and quantity = 3:

  • Total Bill = 100×3=₹300100 \times 3 = ₹300
  • GST = 300×0.05=₹15300 \times 0.05 = ₹15
  • Bill with GST = 300+15=₹315300 + 15 = ₹315
7Write pseudocode that will perform the following:
a) Read the marks of three subjects: Computer Science, Mathematics and Physics, out of 100
b) Calculate the aggregate marks
c) Calculate the percentage of marks
Show solution

Given: Marks of three subjects (each out of 100) are read. Aggregate and percentage are to be calculated.

Formula:
Aggregate=CS+Maths+Physics\text{Aggregate} = \text{CS} + \text{Maths} + \text{Physics}
Percentage=Aggregate300×100\text{Percentage} = \frac{\text{Aggregate}}{300} \times 100

Pseudocode:

BEGIN
  // Part (a): Read marks
  READ cs_marks        // Computer Science marks out of 100
  READ maths_marks     // Mathematics marks out of 100
  READ physics_marks   // Physics marks out of 100

  // Part (b): Calculate aggregate
  aggregate ← cs_marks + maths_marks + physics_marks
  PRINT "Aggregate Marks = ", aggregate

  // Part (c): Calculate percentage
  percentage ← (aggregate / 300) × 100
  PRINT "Percentage = ", percentage, "%"
END

Example: CS = 85, Maths = 90, Physics = 78

  • Aggregate = 85+90+78=25385 + 90 + 78 = 253
  • Percentage = 253300×100=84.33%\dfrac{253}{300} \times 100 = 84.33\%
8Write an algorithm to find the greatest among two different numbers entered by the user.Show solution

Given: Two different numbers are entered by the user. Find the greater one.

Concept: Decision-making (conditional) algorithm.

Algorithm:

BEGIN
  READ num1, num2

  IF num1 > num2 THEN
    PRINT num1, " is the greatest"
  ELSE
    PRINT num2, " is the greatest"
  END IF
END

Explanation:

  • Since the problem states the two numbers are different, we do not need to handle the equal case.
  • If num1 is greater than num2, it is printed as the greatest; otherwise num2 is the greatest.

Example: num1 = 45, num2 = 78 → Output: "78 is the greatest"

9Write an algorithm that performs the following: Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write the word BLUE. If the number is between 25 and 35, write the word ORANGE. If it is any other number, write that ALL COLOURS ARE BEAUTIFUL.Show solution

Given: A number is entered. Print a colour name based on the range it falls in.

Concept: Multi-way decision (if-else if ladder).

Algorithm:

BEGIN
  READ number

  IF (number > 5) AND (number < 15) THEN
    PRINT "GREEN"
  ELSE IF (number > 15) AND (number < 25) THEN
    PRINT "BLUE"
  ELSE IF (number > 25) AND (number < 35) THEN
    PRINT "ORANGE"
  ELSE
    PRINT "ALL COLOURS ARE BEAUTIFUL"
  END IF
END

Note: The boundary values (5, 15, 25, 35) are not explicitly included in any colour range as the problem says "between". If the boundary values are to be included, replace > with >= and < with <= accordingly.

Example: number = 10 → GREEN; number = 20 → BLUE; number = 30 → ORANGE; number = 50 → ALL COLOURS ARE BEAUTIFUL

10Write an algorithm that accepts four numbers as input and find the largest and smallest of them.

Free with a Super Tutor account

11Write an algorithm to display the total water bill charges of the month depending upon the number of units consumed by the customer as per the following criteria:
- for the first 100 units @ ₹5 per unit
- for next 150 units @ ₹10 per unit
- more than 250 units @ ₹20 per unit
Also add meter charges of ₹75 per month to calculate the total water bill.

Free with a Super Tutor account

12What are conditionals? When they are required in a program?

Free with a Super Tutor account

13Match the pairs — Flowchart Symbol with its Function: Flow of Control, Process Step, Start/Stop of the Process, Data, Decision Making.

Free with a Super Tutor account

14Following is an algorithm for going to school or college. Can you suggest improvements in this to include other options?
Reach_School_Algorithm:
a) Wake up b) Get ready c) Take lunch box d) Take bus e) Get off the bus f) Reach school or college

Free with a Super Tutor account

15Write a pseudocode to calculate the factorial of a number (Hint: Factorial of 5, written as 5!=5×4×3×2×15! = 5 \times 4 \times 3 \times 2 \times 1).

Free with a Super Tutor account

16Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 33+73+13=3713^3 + 7^3 + 1^3 = 371.

Free with a Super Tutor account

17Following is an algorithm to classify numbers as 'Single Digit', 'Double Digit' or 'Big'.
Classify_Numbers_Algo:
INPUT Number
IF Number < 9 → 'Single Digit'
Else If Number < 99 → 'Double Digit'
Else → 'Big'
Verify for (5, 9, 47, 99, 100, 200) and correct the algorithm if required.

Free with a Super Tutor account

18For some calculations, we want an algorithm that accepts only positive integers up to 100.
Accept_1to100_Algo:
INPUT Number
IF (0 <= Number) AND (Number <= 100) → ACCEPT
Else → REJECT
a) On what values will this algorithm fail?
b) Can you improve the algorithm?

Free with a Super Tutor account

9 more solved questions in Introduction to Problem Solving

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Introduction to Problem Solving for CBSE Class 11 Computer Science?
Key topics in Introduction to Problem Solving include Problem Solving Basics, Algorithm, Representation of Algorithms, Flowchart Symbols and Basic Examples. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Introduction to Problem Solving free?
The first 9 of the 18 solutions on this page are open to read. The other 9 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Introduction to Problem Solving for Class 11 exams?
Learn the core ideas first, then work through the 45 practice questions on Introduction to Problem Solving. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Introduction to Problem Solving chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Computer Science. Free to start, no card needed.