Algorithm in C
Algorithm in C:
In programming, algorithm is the set of instruction that analyse the problem and develop a step by step procedure to solve problem. Express this procedure as a sequence of instruction is which can be expressed in general English. Such sequence of instruction is known as algorithm.
Example of Algorithm:
1)Write an algorithm to solve c=a + b.
Ans:
Step 1:Start.
Step 2:Read the value of a and b.
Step 3:Put the value of a, b into equation c=a + b.
Step 4:Print the value of c.
Step 5:End.
2)Write an algorithm to find the largest number between two number.
Step 1:Start.
Step 2:Read the value of a, b.
Step 3:If a is greater than b then print a.
Step 4:If b is greater than a then print b.
Step 5:End,
3)Write an algorithm to find the factorial of a given number.
Ans:
Step 1:Start.
Step 2:Read the value of n.
Step 3:For i=1 to n repeat the following step.
a.if (n%i=0) then print the value of i.
Step 4:End.
Comments
Post a Comment