0% found this document useful (0 votes)
70 views6 pages

Algorithms and Flowcharts

The document contains algorithms and flowcharts for solving problems related to roots of quadratic equations, decimal to binary conversion, and reversing a number. For each problem, it provides 9 steps to solve the algorithm and a corresponding flowchart. The document was written by Sarju S, a lecturer in the Department of Computer Science and Engineering.

Uploaded by

Sanif
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Algorithms and Flowcharts

The document contains algorithms and flowcharts for solving problems related to roots of quadratic equations, decimal to binary conversion, and reversing a number. For each problem, it provides 9 steps to solve the algorithm and a corresponding flowchart. The document was written by Sarju S, a lecturer in the Department of Computer Science and Engineering.

Uploaded by

Sanif
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

1Computer Programming

Roots of Quadratic Equation

Algorithm

Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Step 8: Step 9:

Start Read Coefficients a,b,c db2-4ac if (d=0) Then goto Step5 Else goto Step8 r1 -b/2a r2-b/2a Print r1, r2 goto Step13 if (d>0) Then goto Step9 Else goto Step12 r1 -b+sqrt(d)/2a
Department of Computer Science and Engineering

Step 10: r2 -b-sqrt(d)/2a Step 11: Print r1, r2 goto Step13 Step 12: Print Roots are Imaginary Step 13: Stop

Sarju S, Lecturer

2Computer Programming

Flow Chart

Start

"Enter the coefficient a" GET a

"Enter the coefficient b" GET b

"Enter the coefficient c" GET c

d b * b - (4 * a * c)

Yes

d=0

No

r1 - b / (2 * a)

Yes

d>0

No

r2 - b / (2 * a)

r1 ( - b + sqrt(b)) / (2 * a)

PUT "Imaginary Roots"

PUT "Root 1= "+ r1 + "Root 2 = "+ r2

r2 ( - b - sqrt(b)) / (2 * a)

PUT "Root 1= "+ r1 + "Root 2 = "+ r2

End

Decimal to Binary Conversion


Sarju S, Lecturer

Department of Computer Science and Engineering

3Computer Programming

Algorithm

Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Step 8: Step 9: Step10:

Start Read Decimal number dec Set bin 0,i 1 if (dec=0) Then goto Step9 Else goto Step5 r dec%2 bin bin + r * i dec floor (dec/2) i i*10 goto Step4 Print Binary Equivalent bin Stop
Department of Computer Science and Engineering

Flow Chart

Sarju S, Lecturer

4Computer Programming

S rt ta

"E te Th D c a Nme" n r e e im l u br G Td c E e

b in 0

i 1

Lo op

Ys e

N o

r e % dc 2

b in+r *i in b

d c o e / 2) e flo r(d c

i *1 i 0

P T"B a E u a n I "+ U in ry q iv le t s b in

E nd

Reverse of a Given Number Algorithm


Sarju S, Lecturer

Department of Computer Science and Engineering

dc 0 e=

5Computer Programming

Step1: Step2: Step3: Step4: Step5: Step6: Step7: Step8: Step9:

Start Read the Number number Set rev 0 if (number=0) Then goto Step8 Else goto Step5 r number%10 rev r + rev*10 number floor(number/10) goto Step4 Print Reverse Is rev Stop

Flow Chart

Sarju S, Lecturer

Department of Computer Science and Engineering

6Computer Programming

S tart

"Enter The Nu b m er" G number ET

rev 0

Loop

No

r number%10

rev r + rev * 10

number floor(number / 10)

PUT "Reverse of the N m er u b Is"+rev

End

Sarju S, Lecturer

Department of Computer Science and Engineering

Yes

number=0

You might also like