Skip to main content
Chapter 4 of 11
NCERT Solutions

Introduction to Problem Solving

Jharkhand Board · Class 11 · Computer Science

NCERT Solutions for Introduction to Problem Solving — Jharkhand Board Class 11 Computer Science.

45 questions25 flashcards5 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.

1,000+ Class 11 students started this chapter today

18 Questions Solved · 1 Section

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.Show solution
Given: Four numbers are entered. Find the largest and the smallest.

Concept: Sequential comparison using conditional statements.

Algorithm:

```
BEGIN
READ a, b, c, d

// Find Largest
SET largest ← a
IF b > largest THEN largest ← b END IF
IF c > largest THEN largest ← c END IF
IF d > largest THEN largest ← d END IF

// Find Smallest
SET smallest ← a
IF b < smallest THEN smallest ← b END IF
IF c < smallest THEN smallest ← c END IF
IF d < smallest THEN smallest ← d END IF

PRINT "Largest = ", largest
PRINT "Smallest = ", smallest
END
```

Explanation:
- We assume the first number is both the largest and smallest initially.
- We then compare each remaining number and update `largest` or `smallest` if a bigger or smaller value is found.

Example: a=12, b=45, c=7, d=30 → Largest = 45, Smallest = 7
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.
Show solution
Given: Units consumed by a customer. Calculate the water bill using a slab-rate system plus fixed meter charges of ₹75.

Slab structure:
- Units 1–100: ₹5 per unit
- Units 101–250 (next 150 units): ₹10 per unit
- Units above 250: ₹20 per unit

Algorithm:

```
BEGIN
READ units
SET meter_charge ← 75

IF units <= 100 THEN
bill ← units × 5

ELSE IF units <= 250 THEN
bill ← (100 × 5) + ((units - 100) × 10)

ELSE
bill ← (100 × 5) + (150 × 10) + ((units - 250) × 20)

END IF

total_bill ← bill + meter_charge
PRINT "Water Bill (without meter charge) = ₹", bill
PRINT "Meter Charge = ₹", meter_charge
PRINT "Total Water Bill = ₹", total_bill
END
```

Example: units = 300
- First 100 units: 100×5=500100 \times 5 = ₹500
- Next 150 units: 150×10=1500150 \times 10 = ₹1500
- Remaining 50 units: 50×20=100050 \times 20 = ₹1000
- Bill = 500+1500+1000=3000500 + 1500 + 1000 = ₹3000
- Total = 3000+75=30753000 + 75 = ₹3075
12What are conditionals? When they are required in a program?Show solution
Conditionals are statements in an algorithm or program that allow the execution of different sets of instructions based on whether a given condition is true or false.

They implement decision-making in a program.

Common forms:
- IF–THEN: Execute a block only if the condition is true.
- IF–THEN–ELSE: Execute one block if true, another if false.
- IF–ELSE IF–ELSE (ladder): Handle multiple mutually exclusive conditions.

When are conditionals required?

Conditionals are required when:
1. Different actions need to be performed based on different inputs or situations.
*Example:* Checking whether a student has passed or failed based on marks.
2. Validation of input is needed.
*Example:* Accepting only positive numbers.
3. Multiple cases need to be handled.
*Example:* Assigning grades A, B, C based on percentage ranges.
4. Branching in a program is needed so that not all steps are executed every time.

Example:
```
IF marks >= 33 THEN
PRINT "Pass"
ELSE
PRINT "Fail"
END IF
```
Without conditionals, a program would execute every statement sequentially regardless of the situation, making it impossible to handle varying inputs correctly.
13Match the pairs — Flowchart Symbol with its Function: Flow of Control, Process Step, Start/Stop of the Process, Data, Decision Making.Show solution
Note: The actual flowchart symbol images are not visible in the OCR text. The standard NCERT matching is based on universally accepted flowchart symbols:

| Flowchart Symbol | Shape | Function |
|---|---|---|
| Oval / Rounded Rectangle | ⬭ | Start / Stop of the Process |
| Rectangle | ▭ | Process Step |
| Diamond | ◇ | Decision Making |
| Parallelogram | ▱ | Data (Input / Output) |
| Arrow | → | Flow of Control |

Matched Pairs:

1. Oval (Rounded Rectangle)Start/Stop of the Process
2. RectangleProcess Step
3. DiamondDecision Making
4. ParallelogramData
5. ArrowFlow of Control

Explanation:
- The oval marks the beginning and end of a flowchart.
- The rectangle represents any processing action (calculation, assignment).
- The diamond represents a yes/no question — a decision point.
- The parallelogram represents input or output of data.
- Arrows show the direction of flow between steps.
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
Show solution
Analysis of the original algorithm:
The original algorithm assumes only one mode of transport (bus) and does not account for other real-life scenarios.

Improved Algorithm — Reach_School_Algorithm:

```
BEGIN
a) Wake up
b) Check if it is a school/college day
IF holiday THEN
STOP (no need to go)
END IF
c) Get ready (freshen up, have breakfast)
d) Take lunch box
e) Check the weather
IF raining THEN
Take umbrella / raincoat
END IF
f) Choose mode of transport:
IF school bus is available THEN
Take school bus
ELSE IF personal vehicle is available THEN
Travel by personal vehicle (car/bike)
ELSE IF auto-rickshaw/cab is available THEN
Take auto-rickshaw or cab
ELSE
Walk to school/college
END IF
g) Get off at the school/college stop or gate
h) Reach school or college
i) Check if you are on time
IF late THEN
Report to the teacher / take late entry pass
END IF
END
```

Improvements made:
1. Added a check for holidays.
2. Added breakfast and personal preparation steps.
3. Added weather check.
4. Replaced a single transport option (bus) with multiple alternatives: school bus, personal vehicle, auto/cab, or walking.
5. Added a punctuality check on arrival.
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).Show solution
Given: A number nn is entered. Calculate n!n!

Formula:
n!=n×(n1)×(n2)××2×1,0!=1n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1, \quad 0! = 1

Concept: Iterative algorithm using a loop with an accumulator (product).

Pseudocode:

```
BEGIN
READ n

IF n < 0 THEN
PRINT "Factorial is not defined for negative numbers"
ELSE
SET factorial ← 1
SET i ← 1

WHILE i <= n DO
factorial ← factorial × i
i ← i + 1
END WHILE

PRINT "Factorial of ", n, " = ", factorial
END IF
END
```

Dry Run for n = 5:

| Iteration | i | factorial |
|---|---|---|
| Start | 1 | 1 |
| 1 | 1 | 1×1=11 \times 1 = 1 |
| 2 | 2 | 1×2=21 \times 2 = 2 |
| 3 | 3 | 2×3=62 \times 3 = 6 |
| 4 | 4 | 6×4=246 \times 4 = 24 |
| 5 | 5 | 24×5=12024 \times 5 = 120 |

Output: Factorial of 5 = 120
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.Show solution
Given: A 3-digit number is entered. Check if it is an Armstrong number.

Condition: A number nn with digits aa, bb, cc is Armstrong if a3+b3+c3=na^3 + b^3 + c^3 = n.

Algorithm (used to draw the flowchart):

```
BEGIN
READ num
SET temp ← num

// Extract digits
digit1 ← temp MOD 10 // units digit
temp ← temp DIV 10
digit2 ← temp MOD 10 // tens digit
digit3 ← temp DIV 10 // hundreds digit

// Calculate sum of cubes
sum_of_cubes ← (digit1³) + (digit2³) + (digit3³)

// Check condition
IF sum_of_cubes = num THEN
PRINT num, " is an Armstrong number"
ELSE
PRINT num, " is NOT an Armstrong number"
END IF
END
```

Flowchart Description (to be drawn):

1. Oval: START
2. Parallelogram: READ num
3. Rectangle: temp ← num
4. Rectangle: digit1 ← temp MOD 10; temp ← temp DIV 10; digit2 ← temp MOD 10; digit3 ← temp DIV 10
5. Rectangle: sum_of_cubes ← digit1³ + digit2³ + digit3³
6. Diamond: Is sum_of_cubes = num?
- YES → Parallelogram: PRINT "Armstrong number"
- NO → Parallelogram: PRINT "Not an Armstrong number"
7. Oval: STOP

Verification with 371:
- digit1 = 1, digit2 = 7, digit3 = 3
- sum = 13+73+33=1+343+27=3711^3 + 7^3 + 3^3 = 1 + 343 + 27 = 371 ✓ → Armstrong number

Verification with 123:
- digit1 = 3, digit2 = 2, digit3 = 1
- sum = 33+23+13=27+8+1=361233^3 + 2^3 + 1^3 = 27 + 8 + 1 = 36 \neq 123 → Not an Armstrong number
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.
Show solution
Verification of the original algorithm:

| Number | Condition Checked | Output by Original Algo | Expected Output | Correct? |
|---|---|---|---|---|
| 5 | 5 < 9 → True | Single Digit | Single Digit | ✓ |
| 9 | 9 < 9 → False; 9 < 99 → True | Double Digit | Single Digit | ✗ |
| 47 | 47 < 9 → False; 47 < 99 → True | Double Digit | Double Digit | ✓ |
| 99 | 99 < 9 → False; 99 < 99 → False | Big | Double Digit | ✗ |
| 100 | 100 < 9 → False; 100 < 99 → False | Big | Big | ✓ |
| 200 | 200 < 9 → False; 200 < 99 → False | Big | Big | ✓ |

Errors found:
- Number 9 should be "Single Digit" but the algorithm gives "Double Digit" (condition should be `<= 9`, not `< 9`).
- Number 99 should be "Double Digit" but the algorithm gives "Big" (condition should be `<= 99`, not `< 99`).

Corrected Algorithm:

```
BEGIN
INPUT Number

IF Number <= 9 THEN
PRINT "Single Digit"
ELSE IF Number <= 99 THEN
PRINT "Double Digit"
ELSE
PRINT "Big"
END IF
END
```

Re-verification:

| Number | Output | Correct? |
|---|---|---|
| 5 | Single Digit | ✓ |
| 9 | Single Digit | ✓ |
| 47 | Double Digit | ✓ |
| 99 | Double Digit | ✓ |
| 100 | Big | ✓ |
| 200 | Big | ✓ |
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?
Show solution
Part (a): On what values will this algorithm fail?

The algorithm uses the condition: `(0 <= Number) AND (Number <= 100)`

Failures:

1. Number = 0: The condition `0 <= 0` is True, so the algorithm accepts 0. But 0 is not a positive integer, so it should be rejected. ✗

2. Decimal/Float values (e.g., 3.5, 7.8): If the input is a real number, the condition may accept it (e.g., 3.5 satisfies `0 <= 3.5 <= 100`), but the problem requires only integers. ✗

3. Number = 100: The condition accepts 100 (`100 <= 100` is True). This is correct if 100 is to be included. ✓ (acceptable)

Summary of failure: The algorithm fails for 0 (accepts it incorrectly) and for non-integer (decimal) values (does not filter them out).

---

Part (b): Improved Algorithm:

```
BEGIN
INPUT Number

IF (Number = INT(Number)) // Check it is an integer
AND (Number >= 1) // Check it is positive (>= 1, not 0)
AND (Number <= 100) THEN // Check it is within range
PRINT "ACCEPT"
ELSE
PRINT "REJECT"
END IF
END
```

Improvements made:
1. Changed `0 <= Number` to `Number >= 1` so that 0 is rejected (only positive integers are accepted).
2. Added a check `Number = INT(Number)` to ensure only whole numbers (integers) are accepted and decimal values are rejected.

Verification:

| Input | Accepted/Rejected | Correct? |
|---|---|---|
| 0 | Rejected | ✓ |
| 1 | Accepted | ✓ |
| 50 | Accepted | ✓ |
| 100 | Accepted | ✓ |
| 101 | Rejected | ✓ |
| 3.5 | Rejected | ✓ |
| −5 | Rejected | ✓ |

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Introduction to Problem Solving for Jharkhand Board Class 11 Computer Science?
Introduction to Problem Solving covers several key topics that are frequently asked in Jharkhand Board Class 11 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Introduction to Problem Solving — Jharkhand Board Class 11 Computer Science?
Understand the core concepts first, then work through the 45 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Introduction to Problem Solving Class 11 Computer Science?
This page has free step-by-step NCERT Solutions for every exercise question in Introduction to Problem Solving (Jharkhand Board Class 11 Computer Science) — written the way examiners award marks: given, formula, working, answer.

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 — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for Jharkhand Board Class 11 Computer Science.