Skip to content
Computer ScienceCBSE Class 11 · Chapter 4

Introduction to Problem Solving Class 11: Algorithms, Flowcharts, Pseudocode and Decomposition

Updated 14 October 2026 · Fact-checked

Introduction to Problem Solving teaches the steps a programmer follows: analyse the problem, develop an algorithm, code it, then test and debug. In Class 11 Computer Science you write algorithms as flowcharts and pseudocode using sequence, selection and repetition, check them by dry runs, compare algorithms, and break big problems into smaller ones by decomposition.

What Introduction to Problem Solving is about

This chapter opens Unit II, Computational Thinking and Programming - 1, which carries 45 of the 70 theory marks in the school annual exam, shared with the Python chapters. Questions ask you to list the steps of problem solving, draw a flowchart, write pseudocode, find the output or the error by a dry run, and decompose a task.

The 2026-27 syllabus wording is: "Introduction to Problem-solving: Steps for Problem-solving (Analyzing the problem, developing an algorithm, coding, testing, and debugging), representation of algorithms using flowchart and pseudocode, decomposition". So you need:

  • the four steps of problem solving and what happens in each, including the meaning of GIGO and of syntax and logical errors
  • what an algorithm is, why it is needed and the characteristics of a good one
  • flowchart symbols and pseudocode keywords, used for sequence, selection (IF/ELSE) and repetition (WHILE, FOR)
  • verifying an algorithm by a dry run and comparing algorithms by time and space
  • coding in a high-level language, and decomposition (divide and conquer)

The Python programs on this page show how a finished algorithm looks as code; Python syntax itself comes in the next chapters.

Weightage: This chapter is part of Unit II, Computational Thinking and Programming - 1, which carries 45 of the 70 theory marks in the school annual exam together with Getting Started with Python, Flow of Control, Strings, Lists, Tuples and Dictionaries and Introduction to Python Modules.Source: CBSE Computer Science (083) syllabus 2026-27, Class XI distribution of marks, Unit II Computational Thinking and Programming - 1

Key concepts

Steps for problem solving
NCERT section NCERT 4.1, 4.2

A computer solves a problem only after a person has worked out the method. The four steps are:
1. Analysing the problem: read the problem statement carefully, list its main parts and decide exactly what the inputs and outputs are and what the solution must do. A wrong understanding leads to a program that does not serve its purpose.
2. Developing an algorithm: write the solution as exact steps in natural language (or as a flowchart or pseudocode), refining it until it handles every case.
3. Coding: translate the algorithm into a high-level language such as Python, following that language's rules, and document the code for later use.
4. Testing and debugging: run the program with many inputs, including unusual ones, to check that it is correct, meets the user's needs and responds in time. Errors found are debugged (removed) and the program is tested again, until no errors remain. The software industry uses unit, integration, system and acceptance testing for large programs.

GIGO (Garbage In, Garbage Out): the output can only be as correct as the input given.

Worked example

A school wants a program that tells each student their grade from total marks. Name the step at which each happens: (a) deciding that the input is marks out of 500 and the output is a grade; (b) running the program with 0, 500 and 499 marks; (c) writing the steps 'if percentage ≥ 90 then grade A ...'; (d) typing the steps in Python.

Try it first, then show the solutionSolution
  1. Finding inputs and outputs is analysis.
  2. Running with edge values is testing.
  3. Writing exact steps is developing the algorithm.
  4. Typing in Python is coding.

Answer: (a) Analysing (b) Testing and debugging (c) Developing an algorithm (d) Coding.

Algorithm and its characteristics
NCERT section NCERT 4.3

An algorithm is a finite sequence of exact steps which, when followed, solves a problem; it is like a well-written recipe. It is needed because a programmer must plan the roadmap of a program before coding; with a clear algorithm the code is easier to write, to check and to explain to others. The word comes from the name of the Persian mathematician al-Khwarizmi.

A good algorithm has:

  • Precision: each step is stated exactly.
  • Uniqueness: the result of each step depends only on the input and the previous steps.
  • Finiteness: it always stops after a finite number of steps.
  • Input: it receives some input.
  • Output: it produces some output.

While writing one, identify the input, the processing to be done and the output wanted.

Worked example

Is this an algorithm? 'Step 1: Set n = 1. Step 2: Print n. Step 3: Add 2 to n. Step 4: Go to Step 2.' Correct it so that it prints the odd numbers up to 9.

Try it first, then show the solutionSolution
  1. There is no step that stops it, so it breaks the finiteness rule; it is not a proper algorithm.
  2. Add a test: Step 2: While n ≤ 9 repeat Steps 3-4. Step 3: Print n. Step 4: Add 2 to n. Step 5: Stop.

Answer: Not finite as written; adding the test 'while n ≤ 9' makes it print 1, 3, 5, 7, 9 and stop.

Flowcharts
NCERT section NCERT 4.4.1, Table 4.1

A flowchart is a visual representation of an algorithm. Each shape is one kind of step and the arrows show the order:

SymbolNameUse
Oval (rounded rectangle)TerminatorStart and End
RectangleProcessA calculation or action, e.g. sum = a + b
DiamondDecisionA yes/no (true/false) question with two exits
ParallelogramInput/Output (data)Read input or print output
ArrowFlow line (connector)Order of the steps

Rules: one Start and at least one End; every decision has two labelled exits (Yes/No); arrows go from one shape to the next without crossing where possible; a loop is drawn by an arrow returning to an earlier decision.

Worked example

List, in order, the flowchart shapes for: read the length and breadth of a room, compute the area, display the area.

Try it first, then show the solutionSolution
  1. Start: oval.
  2. Input length, breadth: parallelogram.
  3. area = length × breadth: rectangle.
  4. Print area: parallelogram.
  5. End: oval.

Answer: Oval → parallelogram → rectangle → parallelogram → oval, joined by arrows.

Pseudocode
NCERT section NCERT 4.4.2

Pseudocode ('not real code') is an informal, language-like description of an algorithm. It is meant for people to read and cannot be run by a computer. There is no fixed standard, but common keywords are INPUT, COMPUTE, PRINT, INCREMENT, DECREMENT, IF/ELSE, WHILE and TRUE/FALSE. Indentation shows which steps belong inside an IF or a loop.

Pseudocode is quicker to write and change than a flowchart and is close to real code, so it is easy to translate into Python. A flowchart shows the flow more clearly at a glance for small problems.

Worked example

Write pseudocode to read the price of an item and the quantity bought, and print the bill amount after a 10% discount.

Try it first, then show the solutionSolution
  1. INPUT price
    INPUT qty
    COMPUTE amount = price * qty
    COMPUTE amount = amount - 0.10 * amount
    PRINT amount

Answer: The five lines above: two inputs, two computations, one output.

Flow of control: sequence, selection, repetition
NCERT section NCERT 4.5

The flow of control is the order in which steps run.

  • Sequence: the steps run one after another, each exactly once.
  • Selection: a condition is tested and one of two (or more) paths is chosen: IF condition THEN ... ELSE .... In a flowchart this is a diamond with Yes and No exits. Several conditions can be tested in turn (IF ... ELSE IF ... ELSE) for more than two choices.
  • Repetition (iteration, loop): a set of steps is repeated a fixed number of times or while a condition is true: WHILE condition ... . A loop must change something that the condition tests, or it will never stop.

Worked example

Write pseudocode that reads 5 numbers and prints how many of them are negative.

Try it first, then show the solutionSolution
  1. SET count = 0, i = 1
  2. WHILE i <= 5
    INPUT n
    IF n < 0 THEN
    INCREMENT count
    INCREMENT i
  3. PRINT count
  4. This uses all three: sequence (setting values, printing), selection (IF n < 0) and repetition (WHILE i <= 5).

Answer: The pseudocode above; for inputs 4, -2, 0, -7, 3 it prints 2.

Verifying algorithms: the dry run
NCERT section NCERT 4.6

An algorithm must be correct for every possible input, because faulty software in a bank, hospital or spacecraft can do serious harm. To verify it, we go through the steps by hand with sample inputs and note the value of each variable after each step. This is a dry run. It helps to find wrong steps and missing cases.

Choose test inputs carefully: ordinary values, boundary values (such as exactly 60 minutes or exactly the pass mark), and unusual ones (0, negative numbers, equal values). An algorithm that works for one example may fail for another: for instance, adding two durations in hours and minutes is wrong if it forgets to carry 60 minutes into an hour.

Worked example

An algorithm adds two durations given in minutes and seconds: 'total_min = m1 + m2; total_sec = s1 + s2; print total_min, total_sec'. Dry run it for 3 min 40 s + 2 min 35 s, find the error and correct it.

Try it first, then show the solutionSolution
  1. total_min = 5, total_sec = 75: output '5 min 75 s', which is not a valid time.
  2. Correction: IF total_sec >= 60 THEN total_sec = total_sec - 60 and total_min = total_min + 1.
  3. Now the output is 6 min 15 s.

Answer: The algorithm misses the carry when seconds reach 60; with the IF step it gives 6 min 15 s.

Comparing algorithms
NCERT section NCERT 4.7

One problem can have several correct algorithms. To choose, compare how much processing time each needs (time complexity) and how much memory it uses (space complexity). For example, to test whether n is prime you could try dividing by every number from 2 to n - 1, or only by numbers from 2 up to the square root of n: both are correct, but the second does far fewer divisions for a large n, so it is better.

Worked example

How many divisions does each method make, at most, to decide that 97 is prime: (a) divide by 2 to 96; (b) divide by 2 to 9 (since 10 × 10 > 97)?

Try it first, then show the solutionSolution
  1. (a) 2 to 96 is 95 divisions.
  2. (b) 2 to 9 is 8 divisions.
  3. If n had a factor larger than its square root, it would also have one smaller, so (b) is enough.

Answer: (a) 95 (b) 8; method (b) is far more efficient.

Coding
NCERT section NCERT 4.8, 4.2.4

In coding, the finished algorithm is written in a programming language by following its syntax: the rules for spelling, word order and punctuation of statements. Machine language (0s and 1s) is what the computer runs but is very hard to write, so we write source code in a high-level language and use a compiler or interpreter to translate it. The choice of language depends on things such as the platform (operating system) and whether the program is a desktop, mobile or web application.

Two kinds of error to know: a syntax error breaks the language's rules and the program does not run (no output); a logical error lets the program run but gives wrong output, and is found by testing and dry runs.

Worked example

Classify the error: (a) the average of three marks is computed as a + b + c / 3; (b) a print statement is missing its closing bracket.

Try it first, then show the solutionSolution
  1. (a) The program runs but divides only c by 3 (division before addition): wrong output, so a logical error. Fix: (a + b + c) / 3.
  2. (b) Breaks the language rules, so the program cannot run: syntax error.

Answer: (a) Logical error (b) Syntax error.

Decomposition
NCERT section NCERT 4.9

Some problems are too complex to solve in one go. Decomposition means breaking a complex problem into smaller sub-problems, solving each separately (often by different people), testing each, and then combining them into the full solution: 'divide and conquer'. Each sub-problem can be studied in detail, and a sub-problem may itself be broken down further.

A railway reservation system, for example, can be split into train and seat details, searching trains, booking and payment, cancellation and refunds, and printing tickets. Other examples are planning a school event, weather forecasting and a delivery management system.

Worked example

Decompose 'run the school's annual sports day' into at least five sub-problems.

Try it first, then show the solutionSolution
  1. Event list and schedule.
  2. Student registration for events.
  3. Ground, equipment and volunteers.
  4. Recording results and points.
  5. Prizes and the closing ceremony.
  6. Each team handles one part; the parts are put together on the day.

Answer: Schedule; registration; ground and equipment; results; prizes and ceremony (any five reasonable parts).

Introduction to Problem Solving in real life

Each concept, met in an everyday situation. Read the situation, answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.

Selection in an algorithm

Suppose a metro card machine charges ₹20 for a trip up to 5 km and ₹30 for a longer trip, and refuses travel if the card balance is below the fare.

Write the decision steps as pseudocode and give the result for a 7 km trip with a ₹25 balance.

Try it first, then show the solutionSolution
  1. IF distance <= 5 THEN fare = 20 ELSE fare = 30
  2. IF balance >= fare THEN PRINT 'Allowed' and balance = balance - fare ELSE PRINT 'Recharge'
  3. 7 km gives fare 30; 25 < 30.

Answer: The machine prints 'Recharge'.

Memory hook: Every 'if this, then that' in a rule becomes a diamond in a flowchart.

Decomposition

Imagine your class is building a simple canteen ordering app.

Decompose the app into sub-problems that different groups could solve.

Try it first, then show the solutionSolution
  1. Menu and prices; taking an order; computing the bill with any discount; payment; sending the order to the kitchen.
  2. Each group builds and tests one part; then the parts are joined.

Answer: Menu, order, bill, payment and kitchen display (any reasonable split).

Memory hook: Big job, small jobs, join them up.

Testing with boundary values

Suppose a voting-age checker says 'Eligible' when age > 18.

Which test input exposes the error, and what is the fix?

Try it first, then show the solutionSolution
  1. The rule is 18 years or more.
  2. Test age 18: the checker says 'Not eligible', which is wrong.
  3. Fix: use age >= 18.

Answer: Age 18 exposes it; change > to >=.

Memory hook: Always test the exact boundary value.

Topics in this chapter

Introduction to Problem Solving: syntax and key facts

Steps of problem solving
  1. 1.Analyse
  2. 2.Algorithm
  3. 3.Code
  4. 4.Test and debug
Return to an earlier step whenever testing shows a fault.
Good algorithm
Precision, Uniqueness, Finiteness, Input, Output
Also identify input, processing and output first.
Flowchart symbols
Oval: start/end; rectangle: process; diamond: decision; parallelogram: input/output; arrow: flow
A decision has exactly two exits, Yes and No.
Pseudocode keywords
INPUT, COMPUTE, PRINT, INCREMENT, DECREMENT, IF/ELSE, WHILE, TRUE/FALSE
Indent the steps inside IF and WHILE.
Flow of control
Sequence, selection, repetition
Every algorithm is built from these three.
Comparing algorithms
Time complexity (processing time) and space complexity (memory)
Fewer steps for the same result is better.

Introduction to Problem Solving: diagrams to practise

Practise each one on paper: draw it from the checklist, then tick off every label.

Flowchart: largest of three numbers

Draw a flowchart to find the largest of three numbers A, B and C.

Draw

  1. Start oval; parallelogram 'Input A, B, C'.
  2. Diamond 'A > B?'. Yes: diamond 'A > C?'; No: diamond 'B > C?'.
  3. From 'A > C?': Yes → parallelogram 'Print A'; No → 'Print C'.
  4. From 'B > C?': Yes → 'Print B'; No → 'Print C'.
  5. All output boxes join an End oval.

Label

  • Start
  • Input A, B, C
  • A > B?
  • A > C?
  • B > C?
  • Yes / No on every exit
  • Print largest
  • End

Watch out: Label every exit of every diamond; most lost marks here are for missing Yes/No labels.

How the school exam asks Introduction to Problem Solving

The question patterns to expect, and the method that works for each.

Question typeHow it is askedMethod
Steps and definitions"List the steps of problem solving", "What is an algorithm? Give its characteristics", "What is decomposition?" (2-3 marks).Name each step or property and add one line of explanation or an example.
Draw a flowchart"Draw a flowchart to find the largest of three numbers" or "to print the sum of the first n natural numbers" (3-5 marks).Start and End ovals; parallelograms for input and output; diamonds for every condition with Yes/No labels; an arrow back for loops.
Write pseudocode or an algorithmWrite pseudocode to check whether a number is even, to calculate a bill, to count digits (3 marks).Use INPUT, COMPUTE, IF/ELSE, WHILE, PRINT; indent nested steps; make sure the loop variable changes.
Dry runFind the output of a given flowchart or pseudocode for given inputs, or spot why it fails for some input (2-3 marks).Make a table with a column per variable; update it step by step; check boundary inputs.
Decompose a taskBreak an everyday system (library, canteen, exam result) into sub-problems (2-3 marks).List independent parts, each with its own inputs and outputs, and say how they combine.

Tricks to remember Introduction to Problem Solving

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • A-A-C-T

    Analyse, Algorithm, Code, Test: 'All Answers Come from Testing'.

    Use it when: Listing the four steps in order.

  • PUFIO

    Precision, Uniqueness, Finiteness, Input, Output.

    Use it when: Characteristics of a good algorithm.

  • Shapes by job

    Oval = open/close, rectangle = work, diamond = decide, parallelogram = pass data in or out.

    Use it when: Flowchart symbols.

  • S-S-R

    Sequence, Selection, Repetition: 'Step, Steer, Repeat'.

    Use it when: Flow of control.

Introduction to Problem Solving: exam-level solved questions

Ordered from exam level to HOTS. Cover the solution, write your own, then compare step by step.

Example 1: Even or odd pseudocode and flowchart · 3 marks · Short answerExam level

Write pseudocode and list the flowchart shapes to check whether a number is even or odd.

Try it first, then show the solutionSolution
  1. INPUT n
    IF n MOD 2 = 0 THEN
    PRINT 'Even'
    ELSE
    PRINT 'Odd'
  2. Flowchart: Start (oval) → Input n (parallelogram) → 'n MOD 2 = 0?' (diamond) → Yes: Print 'Even', No: Print 'Odd' (parallelograms) → End (oval).

Answer: The pseudocode above; shapes oval, parallelogram, diamond, two parallelograms, oval.

Example 2: Dry run of a loop · 3 marks · Short answerHarder exam level

Dry run and give the output:
SET a = 0, b = 1, k = 1
WHILE k <= 6
PRINT a
COMPUTE c = a + b
SET a = b, b = c
INCREMENT k

Try it first, then show the solutionSolution
  1. k = 1: print 0; a, b = 1, 1.
  2. k = 2: print 1; a, b = 1, 2. k = 3: print 1; a, b = 2, 3.
  3. k = 4: print 2; a, b = 3, 5. k = 5: print 3; a, b = 5, 8. k = 6: print 5. Loop ends at k = 7.
  4. Checked in Python:
    a, b, k = 0, 1, 1
    while k <= 6:
        print(a, end=' ')
        a, b = b, a + b
        k += 1

Answer: 0 1 1 2 3 5 (the first six Fibonacci numbers)

Example 3: Find and fix the logical error · 3 marks · Short answerHarder exam level

This pseudocode should print the average of 5 numbers:
SET sum = 0, i = 1
WHILE i < 5
INPUT x
COMPUTE sum = sum + x
INCREMENT i
PRINT sum / 5
Dry run with the inputs 10, 20, 30, 40, 50 and correct it.

Try it first, then show the solutionSolution
  1. i takes 1, 2, 3, 4: only four numbers are read (10, 20, 30, 40); sum = 100.
  2. Output 100 / 5 = 20, but the true average is 150 / 5 = 30.
  3. Fix: WHILE i <= 5 (or start i at 0).

Answer: It reads only 4 numbers and prints 20; change the condition to i <= 5 to get 30.

Example 4: Electricity bill algorithm · 5 marks · Long answerHOTS / competency

Suppose a board charges ₹3 per unit for the first 100 units, ₹5 per unit for the next 100 and ₹8 per unit beyond 200. Write pseudocode for the bill, and code it in Python to show the bills for 80, 150 and 260 units.

Try it first, then show the solutionSolution
  1. INPUT units
    IF units <= 100 THEN
    bill = units * 3
    ELSE IF units <= 200 THEN
    bill = 100 * 3 + (units - 100) * 5
    ELSE
    bill = 100 * 3 + 100 * 5 + (units - 200) * 8
    PRINT bill
  2. for units in [80, 150, 260]:
        if units <= 100:
            bill = units * 3
        elif units <= 200:
            bill = 100 * 3 + (units - 100) * 5
        else:
            bill = 100 * 3 + 100 * 5 + (units - 200) * 8
        print(units, bill)
  3. 80 × 3 = 240; 300 + 50 × 5 = 550; 300 + 500 + 60 × 8 = 1280.

Answer: 80 240
150 550
260 1280

Example 5: Comparing two algorithms · 3 marks · Short answerHOTS / competency

To find the sum 1 + 2 + ... + n, algorithm P adds the numbers one by one in a loop; algorithm Q computes n × (n + 1) / 2. For n = 1000, how many additions does each do? Which is better and why? Check both give the same answer.

Try it first, then show the solutionSolution
  1. P does 1000 additions in the loop (n of them); Q does one addition, one multiplication and one division whatever n is.
  2. Q's time does not grow with n, so it is better; both use very little memory.
  3. n = 1000
    s = 0
    for i in range(1, n + 1):
        s = s + i
    print(s, n * (n + 1) // 2)

Answer: P: 1000 additions; Q: 3 operations. Both give 500500; Q is better (less time).

Example 6: Decompose a library system · 3 marks · Short answerExam level

Decompose a school library management system into sub-problems and state one input and one output of each.

Try it first, then show the solutionSolution
  1. Book catalogue: input book details; output searchable list.
  2. Member records: input student details; output member ID.
  3. Issue and return: input member ID and book ID; output due date or updated status.
  4. Fines: input return date; output fine amount.
  5. Reports: input records; output list of overdue books.

Answer: Catalogue, members, issue/return, fines, reports, each with its own input and output.

Example 7: Largest of three: trace every path · 2 marks · Short answerHarder exam level

For the largest-of-three flowchart (A > B? then A > C? or B > C?), which input set takes the path A > B: No, B > C: No? Give an example and the output.

Try it first, then show the solutionSolution
  1. A > B is false, so B ≥ A; B > C is false, so C ≥ B.
  2. Example A = 2, B = 5, C = 9; output C = 9.

Answer: Any input with C ≥ B ≥ A, e.g. (2, 5, 9); it prints 9.

Example 8: Count the digits · 2 marks · Short answerHarder exam level

Write pseudocode to count the digits of a positive integer n, and state the result for n = 70051.

Try it first, then show the solutionSolution
  1. INPUT n
    SET count = 0
    WHILE n > 0
    n = n DIV 10
    INCREMENT count
    PRINT count
  2. 70051 → 7005 → 700 → 70 → 7 → 0: five divisions.

Answer: Count = 5.

Case-study practice (Section E style)

Read the situation, then answer every part. In a school exam set on the board pattern this is a 4-mark question split into 1 + 1 + 1 + 1 marks.

Planning a quiz scoring program

Suppose your school's quiz club needs a program for its inter-house quiz. Each of 4 houses answers 10 questions; a correct answer gets +10, a wrong answer -5 and a pass 0. At the end the house with the highest score wins, and a tie must be reported as a tie.

  1. (i) · 1 mark

    Identify the inputs, the processing and the outputs.

    Answer

    Answer: Input: the result (correct, wrong, pass) of each answer for each house. Processing: add +10, -5 or 0 to the house score; compare the totals. Output: each house's score and the winner or a tie.

    This is the analysis step.

  2. (ii) · 1 mark

    Decompose the program into sub-problems.

    Answer

    Answer: Record answers; compute scores; find the highest score; detect a tie; display the scoreboard.

    Each part can be written and tested on its own.

  3. (iii) · 1 mark

    Write pseudocode to compute one house's score from 10 answers coded C, W or P.

    Answer

    Answer: SET score = 0, i = 1
    WHILE i <= 10
    INPUT ans
    IF ans = 'C' THEN score = score + 10
    ELSE IF ans = 'W' THEN score = score - 5
    INCREMENT i
    PRINT score

    A pass adds nothing, so it needs no branch.

  4. (iv) · 1 mark

    Give a test case that checks the tie rule and the expected output.

    Answer

    Answer: Two houses both scoring 70 as the highest (e.g. scores 70, 70, 40, 55): expected output 'Tie between the two houses', not a single winner.

    Testing must include the boundary case of equal top scores.

Where the marks are

How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.

What is an algorithm? List any three characteristics of a good algorithm. [2 marks] (2 marks)

StepMarks
Definition: a finite sequence of exact steps that solves a problem0.5
Any three of precision, uniqueness, finiteness, input, output, each with a short meaning1.5

Write pseudocode to input a number and print whether it is positive, negative or zero. [3 marks] (3 marks)

StepMarks
INPUT n0.5
IF n > 0 THEN PRINT 'Positive'1
ELSE IF n < 0 THEN PRINT 'Negative' ELSE PRINT 'Zero'1
Correct indentation and keywords0.5

Draw a flowchart to input a number n and print the sum of the digits of n. Dry run it for n = 482. [5 marks] (5 marks)

StepMarks
Start, input n, set sum = 0 (oval, parallelogram, rectangle)1
Decision 'n > 0?' with Yes and No exits1
Yes branch: d = n MOD 10, sum = sum + d, n = n DIV 10, arrow back to the decision1.5
No branch: print sum, End0.5
Dry run table: (482, 0) → (48, 2) → (4, 10) → (0, 14); output 141

Where students lose marks in Introduction to Problem Solving

The slips examiners see most often, and what to write instead.

  • Mistake: Using a rectangle for input or output

    Input and output use the parallelogram; the rectangle is for processing.

    Wrong working

    [ Read marks ] drawn as a rectangle

    Right working

    / Read marks / drawn as a parallelogram

    Do this: Check each box: data in or out → parallelogram.

    Usually costs: Half to 1 mark

  • Mistake: Decision box with one exit or unlabelled exits

    A decision always has a Yes and a No path.

    Wrong working

    <n > 0?> with a single arrow onward

    Right working

    <n > 0?> with arrows labelled Yes and No

    Do this: Label both exits of every diamond.

    Usually costs: 1 mark

  • Mistake: A loop whose condition never becomes false

    The variable tested must change inside the loop, or the algorithm is not finite.

    Wrong working

    i = 1
    WHILE i <= 10
    PRINT i

    Right working

    i = 1
    WHILE i <= 10
    PRINT i
    INCREMENT i

    Do this: After writing a loop, find the step that moves it towards stopping.

    Usually costs: 1 mark

  • Mistake: Mixing up syntax and logical errors

    A syntax error stops the program running; a logical error gives wrong output.

    Wrong working

    Writing area = l + b is a syntax error.

    Right working

    area = l + b runs but gives a wrong value: logical error.

    Do this: Ask: does it run? If yes but the answer is wrong, it is logical.

    Usually costs: 1 mark

  • Mistake: Writing Python code when pseudocode is asked

    Pseudocode should be readable steps without language rules; marks go for the logic and keywords.

    Wrong working

    n = int(input())
    if n % 2 == 0: print('Even')

    Right working

    INPUT n
    IF n MOD 2 = 0 THEN PRINT 'Even' ELSE PRINT 'Odd'

    Do this: Use the pseudocode keywords and plain operators.

    Usually costs: Half mark

NCERT exercise guide: Introduction to Problem Solving

What each exercise in the NCERT chapter tests, how to approach it, and a question of the same kind solved step by step. Questions here are written in our own words.

NCERT Chapter 4 exercise: algorithms, flowcharts and pseudocode

What it tests: Writing algorithms, drawing flowcharts and pseudocode for small calculations, conditions and loops; dry runs; decomposition.

How to approach it: First list input, process and output; then choose sequence, selection or repetition; draw or write; finally dry run with two or three inputs, including a boundary value.

Same kind as the 'write pseudocode with a loop' questions

Write pseudocode to print the multiplication table of a number n up to 10, and code it in Python for n = 7 (first three lines of output shown).

Show the solutionSolution
  1. INPUT n
    SET i = 1
    WHILE i <= 10
    PRINT n, 'x', i, '=', n * i
    INCREMENT i
  2. n = 7
    i = 1
    while i <= 10:
        print(n, 'x', i, '=', n * i)
        i = i + 1

Answer: 7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
... up to 7 x 10 = 70

NCERT Chapter 4 exercise: verifying and comparing algorithms

What it tests: Finding the case where an algorithm fails and choosing the more efficient of two algorithms.

How to approach it: Dry run with boundary and unusual inputs; count the steps each algorithm needs for a large input.

Same kind as the 'find the error by dry run' question

An algorithm to find the larger of two numbers says: IF a > b THEN PRINT a ELSE PRINT b. A student claims it fails for some input. Dry run it for (5, 9), (9, 5) and (6, 6). Is the claim right?

Show the solutionSolution
  1. (5, 9): 5 > 9 is false → prints 9. Correct.
  2. (9, 5): prints 9. Correct.
  3. (6, 6): 6 > 6 is false → prints 6, which is still the larger (equal) value.

Answer: The algorithm works for all three cases; the claim is wrong (though a message such as 'equal' could be added).

Practice questions on Introduction to Problem Solving

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQExam level

    Which flowchart symbol is used to show input or output? (a) Rectangle (b) Diamond (c) Parallelogram (d) Oval

    Hint

    Also called the data symbol.

    Answer

    (c) Parallelogram

  2. Q2 · 2 marks · Short answerExam level

    List the four steps of problem solving in order.

    Hint

    Before coding there are two steps.

    Answer

    Analysing the problem, developing an algorithm, coding, testing and debugging.

  3. Q3 · 2 marks · Short answerExam level

    What is decomposition? Give one advantage.

    Hint

    Divide and conquer.

    Answer

    Breaking a complex problem into smaller sub-problems that are solved separately and then combined. Advantage: each part is simpler and can be solved and tested independently, even by different people.

  4. Q4 · 2 marks · Short answerHarder exam level

    Dry run and give the output:
    SET n = 5, f = 1
    WHILE n > 1
    f = f * n
    n = n - 1
    PRINT f

    Hint

    5 × 4 × 3 × 2.

    Answer

    120

  5. Q5 · 1 mark · MCQHarder exam level

    Assertion (A): Pseudocode can be run directly on a computer. Reason (R): Pseudocode uses keywords like INPUT and PRINT. Choose (a) both true, R explains A (b) both true, R does not explain A (c) A false, R true (d) both false.

    Hint

    Pseudo = not real.

    Answer

    (c) A is false (pseudocode is for people and cannot be executed); R is true.

  6. Q6 · 3 marks · Short answerHarder exam level

    Write pseudocode to input marks out of 100 and print 'Distinction' for 75 and above, 'Pass' for 33 to 74 and 'Fail' below 33. Which three inputs would you use to test the boundaries?

    Hint

    Test exactly at the cut-offs.

    Answer

    INPUT m
    IF m >= 75 THEN PRINT 'Distinction'
    ELSE IF m >= 33 THEN PRINT 'Pass'
    ELSE PRINT 'Fail'
    Test with 75, 33 and 32 (and 74).

  7. Q7 · 2 marks · Short answerHarder exam level

    Predict the output:

    count = 0
    n = 1
    while n < 50:
        n = n * 3
        count = count + 1
    print(n, count)
    Hint

    1, 3, 9, 27, 81.

    Answer

    81 4

  8. Q8 · 2 marks · Short answerHOTS / competency

    An algorithm checks if a year is a leap year with 'IF year MOD 4 = 0 THEN leap'. Give a year for which it gives the wrong answer and say what is missing.

    Hint

    Century years.

    Answer

    1900 (divisible by 4 but not a leap year). Missing rule: a century year is a leap year only if it is divisible by 400 (so 2000 is a leap year, 1900 is not).

  9. Q9 · 2 marks · Short answerExam level

    Why is testing done with many inputs and not just one? Explain with an example.

    Hint

    A program can be right for one input and wrong for another.

    Answer

    A program can work for one input but fail for another. For example, a time-adding program may give 5 min 50 s correctly but print 6 min 75 s when the seconds pass 60. Testing many and boundary inputs finds such faults.

  10. Q10 · 3 marks · Short answerHOTS / competency

    Two algorithms search for a roll number in a list of 1000 sorted numbers: one checks every number from the start; the other repeatedly checks the middle and discards half. At most how many checks does the second need, roughly? Which is better?

    Hint

    Halve 1000 until 1 is left.

    Answer

    About 10 checks (1000 → 500 → 250 → ... → 1, since 2^10 = 1024), against up to 1000 for the first. The halving method takes far less time.

  11. Q11 · 3 marks · Short answerHOTS / competency

    Rewrite as pseudocode with a loop: 'Read numbers one by one until the user enters 0, then print how many numbers were entered (not counting the 0).'

    Hint

    Read once before the loop.

    Answer

    SET count = 0
    INPUT x
    WHILE x != 0
    INCREMENT count
    INPUT x
    PRINT count

  12. Q12 · 1 mark · Very short answerExam level

    Name the error type: (a) the program prints the area of a circle as 2πr; (b) the keyword 'while' is written 'whiel'.

    Hint

    Does it run?

    Answer

    (a) Logical error (b) Syntax error.

Test your recall

Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.

  1. 1.What does GIGO stand for?Show answer

    Garbage In, Garbage Out.

  2. 2.Which flowchart symbol is used for a decision?Show answer

    A diamond.

  3. 3.What is a dry run?Show answer

    Working through an algorithm by hand with sample inputs to check it.

  4. 4.Name the three kinds of flow of control.Show answer

    Sequence, selection and repetition.

  5. 5.What does 'pseudo' mean in pseudocode?Show answer

    Not real.

  6. 6.Which characteristic of an algorithm says it must stop?Show answer

    Finiteness.

  7. 7.What two things are compared when choosing between algorithms?Show answer

    Time (processing time) and space (memory) needed.

Best order to study it

  1. The four steps of problem solving and GIGO.
  2. Algorithm: meaning, need and five characteristics.
  3. Flowchart symbols; draw small flowcharts.
  4. Pseudocode keywords; rewrite the same flowcharts as pseudocode.
  5. Sequence, selection and repetition with examples.
  6. Dry runs with boundary inputs; comparing algorithms.
  7. Coding, syntax and logical errors; decomposition.

Quick revision checklist

The night before the exam: can you do each of these without looking?

  • Steps: analyse, develop an algorithm, code, test and debug.
  • Algorithm: finite, exact steps that solve a problem; precise, unique, finite, has input and output.
  • Flowchart: oval start/end, rectangle process, diamond decision, parallelogram input/output, arrows.
  • Pseudocode: human-readable, not executable; INPUT, COMPUTE, PRINT, IF/ELSE, WHILE.
  • Flow of control: sequence, selection, repetition.
  • Dry run = tracing by hand; test boundary and unusual inputs.
  • Compare algorithms by time and memory needed.
  • Decomposition: split a complex problem into smaller ones, solve, test and combine.

Introduction to Problem Solving: frequently asked questions

Do I need to learn standard pseudocode syntax?

No single standard exists. Use clear keywords such as INPUT, COMPUTE, PRINT, IF/ELSE and WHILE, indent the steps inside conditions and loops, and keep one step per line.

Is a flowchart or pseudocode better?

Both represent the same algorithm. A flowchart shows the flow visually and suits small problems; pseudocode is quicker to write and change and is closer to real code. Use whichever the question asks for.

Are time and space complexity calculations in the syllabus?

The syllabus names only the steps of problem solving, flowcharts, pseudocode and decomposition. NCERT section 4.7 explains comparing algorithms by time and space in words; formal complexity notation is not needed.

What is the difference between testing and debugging?

Testing runs the program with chosen inputs to find whether it has errors; debugging is finding the cause of an error and correcting it. After debugging, the program is tested again.

Why must an algorithm be finite?

A procedure that never stops never gives its output, so it does not solve the problem. Each loop must have a condition that eventually becomes false.

Based on: CBSE Computer Science (083) syllabus, Class XI 2026-27; NCERT Computer Science, Textbook for Class XI, Chapter 4 Introduction to Problem Solving (Reprint 2026-27)