C Programming • Introduction to Computer, Programming & algorithms
C Programming / Writing algorithms and flow-charts of simple problems

Writing algorithms and flow-charts of simple problems

Notes 1 Introduction to Computer, Programming & algorithms

After understanding algorithms and flowcharts, we can use them to solve simple computer problems. First, we write the solution as clear step-by-step instructions and then represent the same logic graphically using a flowchart.

Notes

Writing Algorithms and Flowcharts of Simple Problems

After understanding algorithms and flowcharts, we can use them to solve simple computer problems. First, we write the solution as clear step-by-step instructions and then represent the same logic graphically using a flowchart.

💡 Basic Approach

Understand the Problem → Identify Input and Output → Write Algorithm → Draw Flowchart

Example 1: Find the Area of a Circle

This is a simple arithmetic problem. We take the radius as input, apply the formula, and display the area.

Problem

Write an algorithm and flowchart to calculate the area of a circle.

Formula

Area = π × r × r

Algorithm

  1. Start
  2. Input the radius R.
  3. Calculate AREA = π × R × R.
  4. Display AREA.
  5. Stop

Flowchart

START ↓ INPUT RADIUS ↓ AREA = π × R × R ↓ PRINT AREA ↓ STOP

Example

If R = 5 and π = 3.14:

AREA = 3.14 × 5 × 5 = 78.5
📌 Type of Flowchart

This is a linear arithmetic flowchart. It does not require a decision or loop.

Example 2: Find the Largest of Two Numbers

This is a decision-based problem because a condition must be checked before deciding which number is larger.

Problem

Write an algorithm and flowchart to find the largest of two numbers.

Algorithm

  1. Start
  2. Input two numbers A and B.
  3. Check whether A > B.
  4. If the condition is true, display A.
  5. Otherwise, display B.
  6. Stop

Flowchart Logic

START ↓ INPUT A, B ↓ A > B ? ↙ ↘ YES NO ↓ ↓ PRINT A PRINT B ↘ ↙ ↓ STOP

Example

Let A = 25 and B = 18. Since 25 > 18, the output will be:

Largest = 25

📌 Type of Flowchart

This is a decision-based flowchart. The decision symbol is used to create Yes/No paths.

Example 3: Print Numbers from 1 to N

This is an iterative problem because the same operation is repeated until a condition becomes false.

Problem

Write an algorithm and flowchart to print numbers from 1 to N.

Algorithm

  1. Start
  2. Input N.
  3. Set I = 1.
  4. Check whether I ≤ N.
  5. If true, print I.
  6. Increase I by 1.
  7. Repeat the condition check.
  8. If the condition is false, Stop.

Flowchart Logic

START ↓ INPUT N ↓ I = 1 ↓ I ≤ N ? ↙ ↘ YES NO ↓ ↓ PRINT I STOP ↓ I = I + 1 ↓ ↺ Back to condition

Example

If N = 5, the output will be:

1 2 3 4 5
📌 Type of Flowchart

This is an iterative flowchart because the flow returns to the condition and repeats the steps.

Three Common Types of Simple Problems

Type Main Idea Example
Arithmetic Uses formulas and calculations. Area of a circle
Decision-Based Checks a condition and chooses a path. Largest of two numbers
Iterative Repeats steps until a condition becomes false. Print 1 to N

How to Convert an Algorithm into a Flowchart

  1. Identify the Start and Stop.
  2. Identify input and output steps.
  3. Represent calculations using the Process symbol.
  4. Represent conditions using the Decision symbol.
  5. Connect the symbols using flow lines in the correct order.
  6. Check the flow using suitable test data.
🧠 Easy Exam Approach

Whenever a question asks you to write an algorithm and flowchart, first identify: Input → Process → Decision (if required) → Output → Stop.

Quick Revision

Problem Important Point
Area of Circle Input radius → Apply formula → Output area
Largest of Two Input two numbers → Check condition → Output largest
Print 1 to N Initialize → Check condition → Print → Update → Repeat

Important Exam Questions

Short Answer Questions

  1. Write an algorithm to find the area of a circle.
  2. Write an algorithm to find the largest of two numbers.
  3. Write an algorithm to print numbers from 1 to N.
  4. What is the difference between an arithmetic and decision-based flowchart?

Practical / Long Answer Questions

  1. Write an algorithm and draw a flowchart to calculate the area of a circle.
  2. Write an algorithm and flowchart to find the largest of two numbers.
  3. Write an algorithm and flowchart to print numbers from 1 to N.
  4. Explain the steps involved in converting an algorithm into a flowchart.
🎥 Recommended Learning

Watch a simple Hindi explanation of algorithms and flowcharts with basic problem-solving examples.

▶ Watch: Algorithms & Flowcharts — Simple Problems

📝 Handwritten Notes

A short handwritten-style revision sheet containing important algorithms and flowcharts will be provided here.

🧠 Mind Map

Use the mind map to revise arithmetic, decision-based and iterative problem solving.