- 66 Views
- Uploaded on
- Presentation posted in: General

Algorithm

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

- An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
- An algorithm is contains sequence of steps taken to solve a problem.
- The steps are normally "sequence," "selection, " "iteration," and a case-type statement.
- In C, "sequence " are regular statements.
- The "selection" is the "if then else" statement.
- The” iteration “ is satisfied by a number of statements, such as the "while," " do," and the "for,”.

- A sequential solution of any program that written in human language, called algorithm.
- The word derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi.
- In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.

- ALGORITHM
- To perform all arithmetic operations among two numbers.
- Step 1: Start
- Step2 : Read two numbers into A ann B.
- Step 3: Compute C = A + B , D = A – B , E = A * B , F = A / B
- Step 4: Print “Sum=” C , “Difference=” D ,”Product “E and “Division =” F
- Step 5: Stop

- ALGORITHM
- To find roots of give quadratic equation
- Step 1: Start
- Step2: Read 3 no’s into a,b,c
- Step3: let d=b^2-4ac
- Step4: if d>0,print roots are real and distinct and
- r1=(-b+sqrt(d))2a
- and r2=(-b-sqrt(d)/2a
- print r1,r2
- Step5: else if d=0, print roots are Equal and r=-b/2a print r
- Step6: else print roots are imaginary
- Step: stop

- ALGORITHM
- To print first n even numbers
- Step1: Start
- Step2: Read a number in to N
- Step3: I=1
- Step4: if(i mode2=0), print I
- Step5: I=I+1
- Step6: IfI<=2*N, go to step 4
- Step 7: Stop

- ALGORITHM
- To generate the Fibonacci series
- Step 1: Start
- Step 2: Let A=-1,B=1,I=1C.
- Step 3: Read Limit to N
- Step 4: Evaluate C=A+B, Print C, A=B, B=C,I=I+1
- Step 5: if I<=N Then Goto Step 4
- Step 6: Stop

- ALGORITHM
- To search an element in an array and to print its position.
- Step 1: start
- Step 2: read limit into N
- Step 3:print enter array
- Step 4: I=0
- Step 5: readA[I]
- Step 6: I+1,I<N go to step 4
- Step 7: print given array
- Step 8:I=0
- step 9: print A[I]
- Step 10: I+1,I<N go to step 9
- Step 11: read ITEM
- Step 12: F=0
- Step 13: I=0
- Step 14: if A[I] =ITEM
- Step 15: print A[I] and I
- Step 16: F=1
- Step 17: I+1,if I<N go to step 15
- Step 18: if F=0
- Step 19: print item not found
- Step 20: stop

- ALGORITM
- To sort an array
- Step 1: Start
- Step 2: Initialize A[10],I=0,j,n,t
- Step 3: Read limit into n
- Step 4: Print “enter the array element”
- Step 5: Read A[i]
- Step 6: I=I+1, IF I<N THEN goto Step 5
- Step 7: Print “The given Array” I=0
- Step 8: Print A[I] I=I+1
- Step 9: If I<N THEN goto Step 8
- Step 10:SET I=0
- Step 11:SET J=0
- Step 12:IF A[I]>A[J] THEN
- Step 13: T=A[I]
- Step 14:A[I]=A[J]
- Step 15:A[J]=T
- Step 17:J=J+1, If J<N THEN goto step 12
- Step 18:I=I+1, If I<N THEN goto Step 11
- Step 19:Print “Sorted Array “;
- Step 20:set I=0
- Step 21: Print A[I], I=I+1
- Step 22: If I<N THEN Goto Step 21
- Step 23: Stop