C Programming • Introduction to Computer, Programming & algorithms
C Programming / Algorithm — Definition

Algorithm — Definition

Notes 1 Introduction to Computer, Programming & algorithms

An algorithm is a finite sequence of well-defined and unambiguous steps used to solve a problem or perform a task. It takes input, processes it step-by-step, and produces the required output.

Notes

What is an Algorithm?

An algorithm is a finite sequence of well-defined and unambiguous steps used to solve a problem or perform a task. It takes input, processes it step-by-step, and produces the required output.

Real-World Example

🌍 Real World Example

A recipe for making tea is similar to an algorithm. It gives instructions in a particular order, such as boiling water, adding tea leaves, adding milk and sugar, and finally serving the tea.

Algorithm in Computer Problem Solving

Before writing a program, a programmer can first design an algorithm to describe the solution logically. The algorithm can then be converted into a program using a programming language such as C.

PROBLEM ↓ ALGORITHM ↓ PROGRAM ↓ OUTPUT

Example: Algorithm to Add Two Numbers

  1. Start
  2. Input two numbers A and B.
  3. Calculate Sum = A + B.
  4. Display the value of Sum.
  5. Stop

Example in Simple Form

START ↓ INPUT A, B ↓ SUM = A + B ↓ PRINT SUM ↓ STOP

Important Points About an Algorithm

  • It provides a step-by-step solution.
  • Each step should be clear and understandable.
  • The steps should eventually terminate.
  • An algorithm is independent of a particular programming language.
  • It can be represented using natural language, pseudocode, or a flowchart.
💡 In Simple Words

An algorithm is simply a step-by-step plan for solving a problem. First we decide the logic, and then we write the program.

Algorithm vs Program

Algorithm Program
A logical step-by-step solution. The solution written using a programming language.
Language independent. Written in a specific programming language.
Focuses on logic. Focuses on implementing the logic.

Quick Revision

Point Remember
Meaning Step-by-step procedure to solve a problem.
Nature Logical and language independent.
Input Data required to solve the problem.
Output Required result of the problem.
Representation Natural language, pseudocode or flowchart.

Important Exam Questions

Short Answer Questions

  1. What is an algorithm?
  2. Why is an algorithm used in problem solving?
  3. Write the important features of an algorithm.
  4. Is an algorithm dependent on a programming language?
  5. Write an algorithm to add two numbers.

Long Answer Questions

  1. Define an algorithm and explain its role in computer problem solving.
  2. Write and explain an algorithm to add two numbers.
  3. Differentiate between an algorithm and a program.
🎥 Recommended Learning

Watch a simple Hindi explanation of algorithms and basic problem solving.

▶ Watch: Algorithm Definition & Examples — Hindi

📝 Handwritten Notes

A short handwritten-style revision sheet for Algorithm Definition will be provided here.

🧠 Mind Map

Use the mind map for quick revision of algorithm, input, processing and output.