Algorithm

Planning a program involves defining its logic (the correct sequence of instructions needed to solve the problem at hand) called Algorithm. It is a step-by – step description of how to arrive at a solution to a given problem.

Algorithm – Number Calculation

1. Write an algorithm for input two number and calculate them.

Step-1 Start

Step-2 Input two number into A, B

Step-3 C=A+B

Step-4 Display C

Step-5 Stop

2. Write an algorithm for show the result of (A+B)/C, (A+B)*(B-C).

Step-1 Start

Step-2 Input three number into A,B,C

Step-3 D=(A+B)/C

Step-4 E=(A+B)*(B-C)

Step-5 Display D,E

Step-6 Stop

Algorithm – Highest & Lowest Value

3. Write an algorithm for input three number and show the highest, lowest value.

Step-1 Start

Step-2 Input three number into A,B,C

Step-3 M=MAX(A,B,C)

Step-4 N=MIN(A,B,C)

Step-5 Display M,N

Step-6 Stop

Algorithm – Temperature Converter

4. Write an algorithm for input temperature number in Celsius, Fahrenheit and convert to opposite temperature number.

Step-1 Start

Step-2 Input temperature number in Celsius, Fahrenheit into C, F

Step-3 CF=9*C/5+32

Step-4 CC=(5*F-160)/9

Step-5 Display CF, CC

Step-6 Stop

Algorithm – Marksheet

5. Write an algorithm for input Student Name, Six Subject number and calculate best of five Total, Average, Grade.

*Note:

Grade “A+” for Average>=90

Grade “A” for Average>=80

Grade “B+” for Average>=70

Grade “B” for Average>=60

Grade “C” for Average>=50

Grade “D” for Average>=40

Otherwise Grade “Fail”

Step-1 Start

Step-2 Input Student Name, Six Subject number into N, B, E, G, H, M, C

Step-3 L=MIN(G,H,M,C)

Step-4 T=(B+E+G+H+M+C)-L

Step-5 A=T/5

Step-6 If A>=90 Then D=”A+” Goto Step-13

Step-7 Elseif A>=80 Then D=”A” Goto Step-13

Step-8 Elseif A>=70 Then D=”B+” Goto Step-13

Step-9 Elseif A>=60 Then D=”B” Goto Step-13

Step-10 Elseif A>=50 Then D=”C” Goto Step-13

Step-11 Elseif A>=40 Then D=”D” Goto Step-13

Step-12 Else D=”Fail”

Step-13 Display T, A, D

Step-14 Stop

Algorithm – Serial Number

7. Write an algorithm for show 1 2 3..ten natural number.

Step-1 Start

Step-2 A=1, K=1

Step-3 Display A

Step-4 A=A+1

Step-5 K=K+1

Step-6 If K<=10 Then goto Step-3

Step-7 Stop

Algorithm – Ten *

8. Write an algorithm for show ten *.

Step-1 Start

Step-2 A=1, K=1

Step-3 Display “*”

Step-4 A=A+1

Step-5 K=K+1

Step-6 If K<=10 Then goto Step-3

Step-7 Stop

Algorithm – 1 3 5 7..upto 10 Number

9. Write an algorithm for show 1 3 5 7..upto 10 number.

Step-1 Start

Step-2 A=1, K=1

Step-3 Display A

Step-4 A=A+2

Step-5 K=K+1

Step-6 If K<=10 Then goto Step-3

Step-7 Stop

Algorithm – 5 9 13 17..upto 10 Number

10. Write an algorithm for show 5 9 13 17..upto 10 number.

Step-1 Start

Step-2 A=5, K=1

Step-3 Display A

Step-4 A=A+4

Step-5 K=K+1

Step-6 If K<=10 Then goto Step-3

Step-7 Stop

Algorithm – 1 8 27 64..upto 10 Number

11. Write an algorithm for show 1 8 27 64..upto 10 number.

Step-1 Start

Step-2 A=1, K=1

Step-3 Display A*A*A

Step-4 A=A+1

Step-5 K=K+1

Step-6 If K<=10 Then goto Step-3

Step-7 Stop

Algorithm – 5 9 14 20..upto 10 Number

12. Write an algorithm for show 5 9 14 20..upto 10 number.

Step-1 Start

Step-2 A=5, B=4, K=1

Step-3 Display A

Step-4 A=A+B

Step-5 B=B+1

Step-6 K=K+1

Step-7 If K<=10 Then goto Step-3

Step-8 Stop

Algorithm – A B C D..upto 26 Character

13. Write an algorithm for show A B C D..upto 26 character.

Step-1 Start

Step-2 A=65, K=1

Step-3 Display CHR(A)

Step-4 A=A+1

Step-5 K=K+1

Step-6 If K<=26 Then goto Step-3

Step-7 Stop

Algorithm – Name Pyramid Structure

14. Write an algorithm for input “JYCTC” and show in Pyramid Structure.

J

JY

JYC

JYCT

JYCTC

Step-1 Start

Step-2 J=”JYCTC”, K=1

Step-3 L=LEN(J)

Step-4 Display LEFT(J,K)

Step-5 K=K+1

Step-6 If K<=L Then goto Step-4

Step-7 Stop

15. Write an algorithm for input “JYCTC” and show in Pyramid Structure.

JYCTC

JYCT

JYC

JY

J

Step-1 Start

Step-2 J=”JYCTC”, K=1

Step-3 L=LEN(J)

Step-4 N=L

Step-5 Display LEFT(J,N)

Step-6 N=N-1

Step-7 K=K+1

Step-8 If K<=L Then goto Step-5

Step-9 Stop

16. Write an algorithm for input “JYCTC” and show in Pyramid Structure.

J

JY

JYC

JYCT

JYCTC

JYCT

JYC

JY

J

Step-1 Start

Step-2 J=”JYCTC”, K=1, M=1

Step-3 L=LEN(J)

Step-4 Display LEFT(J,K)

Step-5 K=K+1

Step-6 If K<=L Then goto Step-4

Step-7 N=L-1

Step-8 P=N

Step-9 Display LEFT(J,P)

Step-10 P=P-1

Step-11 M=M+1

Step-12 If M<=N Then goto Step-9

Step-13 Stop

Algorithm – Opposite Character

17. Write an algorithm for input “COMPUTER” and show it as “RETUPMOC” (Opposite Character).

Step-1 Start

Step-2 Z=””, C=”COMPUTER”, K=1

Step-3 L=LEN(C)

Step-4 N=SUBSTR(C,L,1)

Step-5 Z=Z+N

Step-6 L=L-1

Step-7 K=K+1

Step-8 If K<=L Then goto Step-4

Step-9 Display Z

Step-10 Stop