What is algorithm ?

Algorithm is just the stepwise analysis of any program or problem that means whenever we divide any problem into some steps of its subproblems then we got the algorithm of that problem or program 

for example :

Write a algorithm make tea  

STEP 1 : Start 

STEP 2 : boil the water in a saucepan

STEP 3 : Add the tea to boiling water

STEP 4 : Add milk and sugar into boiling water 

STEP 5 : Boil these all ingredients for 2-3 minutes 

STEP 6 : sieve the tea into the cup

STEP 7 : STOP

here all these 7 steps represent the algorithm to make tea similarly in c programming we have to make algorithms for each program these was the best technique to understand the logic behind the program or coding 

Characteristics of algorithms :

every stepwise analysis is not an algorithms they must have some specific characteristics 
1. Unambiguous :
 unambiguous means the algorithm must have clean inputs outputs and easily understandable 
2. Input :
algorithm must have at least 0 or more well-defined inputs
3. Output :
Algorithm must have the at least 1 output and these output should match with desired output 
4. Finiteness :
Algorithm must terminated after finite number of steps 
5. Feasibility :
Algorithms should be feasible with available resources 
6. Independent :
Algorithm should be independent from any programming language 

These are the characteristic of algorithms 

following are the some examples of writing algorithm  :

Que 1) Write a algorithm to add two numbers 

STEP 1 : Start 

STEP 2 : Declare variable to store numbers num1, num2 and sum

STEP 3 : Read values in num1 and num2 variable by user

STEP 4 : Add num1 and num2 and assign the result into sum (i.e. sum=num1+num2)

STEP 5 : display sum  

STEP 6 : STOP

Que 2) Write a algorithm to find the number is prime or not 

STEP 1 : Start 

STEP 2 : Read number n

STEP 3 : Set flag=0

STEP 4 : For i=2 to (n-1)

STEP 5 : condition if n mod 1 =0 then set flag=1 and break 

STEP 6 : loop

STEP 7 : If flag=0 then print "number is prime" else print "number is not prime"

STEP 8 : STOP

Que 3) Write a algorithm to find the number is even or odd

STEP 1 : Start 

STEP 2 : Read number num

STEP 3 : divide the number by 2 and store remainder in rem

STEP 4 : If rem=0 then go to step 6

STEP 5 : print "Number is odd" go to step 7

STEP 6 : print "number is even"

STEP 7 : STOP

so these all about the algorithms if you like these post please share with your friends and support us 

Thank you !!