Current Affairs updated daily
KalviGavaniKalviGavani
Class 11 · CBSE

Introduction to Problem Solving — NCERT Class 11 Computer Science

Complete NCERT Solutions for CBSE Class 11 Computer Science Chapter 4 — all exercise questions on algorithms, flowcharts, pseudocode, and problem solving steps answered clearly.

Updated 11 June 202613 min read

Introduction to Problem Solving — NCERT Class 11 Computer Science Exercise Solutions

How to Use This Page

This page provides complete solutions for all exercise questions from NCERT Class 11 Computer Science Chapter 4 — Introduction to Problem Solving. Each answer follows the CBSE marking scheme format.

Tips for best results:

  • Attempt each question on your own before reading the solution
  • Compare your algorithm or flowchart with the one given here
  • Pay close attention to how algorithms are structured — step numbering, START/STOP, indentation
  • Practise drawing flowcharts on paper; the exam requires hand-drawn diagrams

Key Concepts — Quick Review

Before the solutions, here is a brief recap of the core concepts:

ConceptOne-Line Summary
Problem Solving StepsUnderstand, Analyse, Design, Code, Test, Maintain
AlgorithmStep-by-step procedure with finiteness, definiteness, input, output, effectiveness
FlowchartVisual representation using oval (terminal), rectangle (process), parallelogram (I/O), diamond (decision)
PseudocodeStructured English-like description of an algorithm
Syntax ErrorViolation of language grammar rules; caught before execution
Logical ErrorProgram runs but gives wrong output due to flawed logic
Runtime ErrorProgram crashes during execution (e.g., division by zero)

Exercise Questions and Answers

Q1: Write an algorithm to find the sum of two numbers.

Answer
Step 1: START Step 2: Read the first number A Step 3: Read the second number B Step 4: Set SUM = A + B Step 5: Display SUM Step 6: STOP
ExplanationThe algorithm reads two input values, adds them, and displays the result. It satisfies all five properties: it is finite (6 steps), definite (each step is clear), has input (A and B), has output (SUM), and each step is basic and executable.

Q2: Write an algorithm and draw a flowchart to find the maximum of three numbers.

Answer

Algorithm:

Step 1: START Step 2: Read three numbers A, B, C Step 3: Set MAX = A Step 4: If B > MAX, then set MAX = B Step 5: If C > MAX, then set MAX = C Step 6: Display MAX Step 7: STOP

Flowchart:

[START] | [/Read A, B, C/] | [MAX = A] | <B > MAX?> / \ Yes No | | [MAX = B] | | | +----+----+ | <C > MAX?> / \ Yes No | | [MAX = C] | | | +----+----+ | [/Display MAX/] | [STOP]
ExplanationWe first assume A is the maximum. Then we compare B and C with the current MAX. If any number is greater, we update MAX. After both comparisons, MAX holds the largest value.

Q3: Write pseudocode to calculate the factorial of a number.

Answer
READ N FACT = 1 I = 1 WHILE I <= N DO FACT = FACT * I I = I + 1 ENDWHILE DISPLAY FACT
ExplanationThe variable FACT is initialised to 1. The loop runs from I = 1 to I = N. In each iteration, FACT is multiplied by the current value of I, and I is incremented by 1. When the loop ends, FACT contains the product 1 x 2 x 3 x ... x N, which is N factorial.

Example trace for N = 4:

IterationI (before)FACT (before)FACT (after)I (after)
11112
22123
33264
446245

When I becomes 5, the condition I <= N (5 <= 4) is false, so the loop stops. FACT = 24, which is 4!.


Q4: List and explain the properties of a good algorithm.

Answer

A good algorithm must possess the following five properties:

1. Finiteness: The algorithm must terminate after a finite and known number of steps. An algorithm that runs forever (infinite loop) is not valid. For example, an algorithm that keeps adding 1 to a counter without a stopping condition is not finite.

2. Definiteness: Every step of the algorithm must be precisely and unambiguously defined. There should be no room for multiple interpretations. For example, a step that says "add some number" is ambiguous, while "add A and B" is definite.

3. Input: An algorithm may have zero or more inputs. The inputs are the data values the algorithm works with. Some algorithms (like one that prints a fixed message) may have zero inputs, but most algorithms require at least one input.

4. Output: An algorithm must produce at least one output. The output is the result of the computation. An algorithm that produces no output serves no purpose and is not considered valid.

5. Effectiveness: Every step of the algorithm must be basic enough that it can be performed exactly in a finite amount of time using basic operations. For example, a step that says "find the largest number in an infinite list" is not effective because it cannot be completed.


Q5: Differentiate between syntax errors and logical errors.

Answer
AspectSyntax ErrorLogical Error
DefinitionViolation of the grammatical rules of a programming languageFlaw in the algorithm or logic that produces incorrect results
When detectedDuring compilation or before executionDuring execution or when checking output
Effect on programProgram does not run at allProgram runs but gives wrong output
CauseMisspelled keywords, missing colons, unmatched brackets, wrong indentationWrong formula, incorrect condition, using wrong variable
ExampleWriting pritn instead of print, forgetting a closing parenthesisCalculating area as length + width instead of length * width
Ease of detectionEasy — compiler shows the exact line and error typeDifficult — the program runs without complaint; only the output is wrong
FixCorrect the syntax according to language rulesTrace the logic, identify the flaw, and correct the algorithm

Example of syntax error (Python):

# Wrong — missing colon after if
if x > 5
    print("Greater")

Example of logical error (Python):

# Runs without error but gives wrong result
# Should be multiplication, not addition
area = length + width

Q6: Explain the standard flowchart symbols and their uses.

Answer

Flowcharts use standard geometric symbols defined by ANSI (American National Standards Institute) to represent different types of operations:

Symbol NameShapePurposeExample
TerminalOval or rounded rectangleMarks the beginning (START) or end (STOP) of the programSTART, STOP
ProcessRectangleRepresents a processing step or calculationSUM = A + B, COUNT = COUNT + 1
Input/OutputParallelogramRepresents reading input from the user or displaying outputRead N, Display RESULT
DecisionDiamond (rhombus)Represents a conditional check with two possible paths (Yes/No)Is N > 0?, Is A == B?
Flow LineArrowShows the direction of flow from one step to the nextConnects all symbols in sequence
ConnectorSmall circleConnects parts of a flowchart on the same page or across pagesUsed in large flowcharts to avoid crossing lines
Predefined ProcessRectangle with double side edgesRepresents a call to a sub-program or predefined functionCALL Sort_Array, CALL Calculate_Average

Important rules:

  • The decision symbol always has one entry and two exits (Yes and No)
  • The flow direction is typically top-to-bottom or left-to-right
  • Every flowchart must begin with START and end with STOP
  • Flow lines should not cross; use connectors if needed

Q7: Write pseudocode and draw a flowchart to check whether a given number is even or odd.

Answer

Pseudocode:

READ N IF N MOD 2 = 0 THEN DISPLAY "Even" ELSE DISPLAY "Odd" ENDIF

Flowchart:

[START] | [/Read N/] | [R = N MOD 2] | <R = 0?> / \ Yes No | | [/Display [/Display "Even"/] "Odd"/] | | +---+---+ | [STOP]
ExplanationThe number N is read as input. N MOD 2 calculates the remainder when N is divided by 2. If the remainder is 0, the number is even; otherwise, it is odd.

Q8: Write an algorithm to find the sum of the first N natural numbers.

Answer
Step 1: START Step 2: Read N Step 3: Set SUM = 0 Step 4: Set I = 1 Step 5: Repeat Steps 6-7 while I <= N Step 6: Set SUM = SUM + I Step 7: Set I = I + 1 Step 8: Display SUM Step 9: STOP
ExplanationThe algorithm initialises SUM to 0 and I to 1. The loop adds I to SUM in each iteration and increments I by 1. When I exceeds N, the loop stops. SUM now holds the value 1 + 2 + 3 + ... + N.

Verification: For N = 5, the loop runs 5 times. SUM = 1 + 2 + 3 + 4 + 5 = 15. The mathematical formula N(N+1)/2 gives 5(6)/2 = 15. The result matches.


Q9: What are the different steps involved in problem solving? Explain briefly.

Answer

Problem solving in computer science follows a systematic approach with six well-defined steps:

1. Understanding the Problem: This is the most critical step. Read the problem statement carefully and identify what is given (inputs), what is required (outputs), and any constraints or special conditions. A misunderstood problem leads to a wrong solution.

2. Analysing the Problem: Break the problem down into smaller components. Identify the relationships between inputs and outputs. Consider multiple approaches and choose the most efficient one. Think about edge cases and boundary conditions.

3. Designing the Solution: Develop the algorithm — a step-by-step procedure to solve the problem. You can represent the solution as an algorithm, flowchart, or pseudocode. This step focuses on "what to do" and "in what order."

4. Coding the Solution: Translate the algorithm or pseudocode into a programming language (Python for CBSE). Follow the syntax rules of the language. Write clean, well-commented code.

5. Testing and Debugging: Run the program with various inputs and compare the output with expected results. If errors are found, debug and fix them. Test with normal inputs, boundary values, and invalid inputs.

6. Maintenance: After the program is deployed, it may need updates for new requirements, performance improvements, or bug fixes discovered in real-world use.


Q10: Write pseudocode to find the largest element in a list of numbers.

Answer
READ N READ LIST[1], LIST[2], ..., LIST[N] MAX = LIST[1] I = 2 WHILE I <= N DO IF LIST[I] > MAX THEN MAX = LIST[I] ENDIF I = I + 1 ENDWHILE DISPLAY MAX
ExplanationThe algorithm assumes the first element is the maximum. It then iterates through the remaining elements. If any element is greater than the current MAX, MAX is updated. After all elements are checked, MAX holds the largest value in the list.

Example trace for LIST = [12, 45, 7, 89, 23]:

ILIST[I]MAX (before)LIST[I] > MAX?MAX (after)
24512Yes45
3745No45
48945Yes89
52389No89
ResultMAX = 89

Q11: What is the difference between a runtime error and a logical error? Give examples.

Answer
AspectRuntime ErrorLogical Error
When it occursDuring program executionDuring program execution or only visible in output
What happensThe program crashes or stops unexpectedlyThe program runs completely but produces wrong results
CauseAttempting an operation that cannot be performed at that momentIncorrect logic, wrong formula, or flawed algorithm
DetectionThe program stops with an error messageNo error message; the programmer must verify output manually
ExamplesDivision by zero, accessing an array element beyond its bounds, running out of memoryCalculating average as (a + b + c) / 2 instead of /3, using < instead of <= in a loop condition

Example of runtime error:

a = 10
b = 0
result = a / b  # ZeroDivisionError — program crashes

Example of logical error:

a = 10
b = 20
c = 30
average = (a + b + c) / 2  # Wrong: should be /3
# Program runs but gives 30.0 instead of correct 20.0

Q12: Write an algorithm to find whether a given number is positive, negative, or zero.

Answer
Step 1: START Step 2: Read the number N Step 3: If N > 0, then display "Positive" and go to Step 6 Step 4: If N < 0, then display "Negative" and go to Step 6 Step 5: Display "Zero" Step 6: STOP

Pseudocode version:

READ N IF N > 0 THEN DISPLAY "Positive" ELSE IF N < 0 THEN DISPLAY "Negative" ELSE DISPLAY "Zero" ENDIF
ExplanationThe algorithm first checks if N is greater than zero. If yes, the number is positive. If not, it checks if N is less than zero, which means the number is negative. If neither condition is true, N must be zero.

Related Resources

  • [CBSE Class 11 Introduction to Problem Solving — Chapter Guide](/class/11/computer-science/cbse-introduction-problem-solving) — Complete chapter notes with detailed concepts, comparison tables, and exam tips
  • [CBSE Class 11 Emerging Trends — Exercise Solutions](/class/11/computer-science/solutions/cbse-emerging-trends-exercise-solutions) — Chapter 3 solutions
  • [CBSE Class 11 Computer Science — Computer System](/class/11/computer-science/cbse-computer-system) — Chapter 1 notes
  • [CBSE Class 11 Computer Science — Getting Started with Python](/class/11/computer-science/cbse-getting-started-python) — Chapter 5 notes

Frequently Asked Questions

This page has complete NCERT exercise solutions for CBSE Class 11 Computer Science Chapter 4 Introduction to Problem Solving.
← Browse all Class 11 Exercise Solutions

Other question types — same chapter