Type Here to Get Search Results !
திருக்குறள் / Thirukkural of the Day
Thiruvalluvar

CS25C01 Computer Programming C Algorithm

MK 0

Algorithm

An algorithm is a step-by-step set of instructions written in simple English to solve a specific problem.

Example:

            
Think of an algorithm like a recipe for cooking a dish or a set of directions to reach a destination.


Example: How to Add Two Numbers

Imagine you want to tell a computer how to add two numbers. Here is how you write it down step by step:

Step 1: Start
Step 2: Read the first number in variable 'a'
Step 3: Read the second number in variable 'b'
Step 4: Perform the addition (a + b) of both the numbers and store the result in variable 'c'.
Step 5: Print the value of 'c' as a result of addition.
Step 6: Stop

Key Characteristics of an Algorithm

Every good algorithm must follow 5 simple rules:

  • Input: It takes zero or more inputs (things you give it to work on).
  • Output: It must produce at least one output (the final answer).
  • Definiteness: Every step must be clear, simple, and have only one meaning (no confusion).
  • Finiteness: It must finish after a countable number of steps—it should never run forever.
  • Effectiveness: Every step must be simple enough that anyone can follow it using just a pencil and paper.

Try it Yourself 👍

  1. Find the area of a circle of radius r.
  2. Adding 3 numbers.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.