Sie sind auf Seite 1von 5

NAMA : DAVID PUTRA SIMANJUNTAK

NIM : 4221901059

PRODI : ROBOTIKA (B)

1. Design an algorithm and the corresponding flowchart for finding the sum of the numbers 2, 4, 6, 8, …,
n

A. Algoritma

Start

sum = 0

Get a value n

For(i = 2, n, i+2)

sum = sum + value

ENDFOR

Output sum

Stop

B. FLOWCHART

START

Sum = 0
I=2

Get a
value n

True
i >= n

False

Sum = sum + i Outptut


sum

i=i+2
STOP
2. Using flowcharts, write an algorithm to read 100 numbers and then display the sum.

A. Algoritma

Start

sum = 0

for(i=1, i<=100, i++)

get number

sum = sum + number

End

Output sum

Stop

B. FLOWCHART

START

Sum = 0

I=1

I <=
100

Get a
number
Display
sum

sum = sum +
number
STOP
3. Write an algorithm to read two numbers then display the largest.

A. algoritma

Start

get 1, 2;

If a>b

Display a;

Else b>a

Display b;

End If

Stop

4. Write an algorithm to read two numbers then display the smallest

Start

Read a, b;

If a>b

Display b;

Else b>a

Display a;

End If

Stop
5. Write an algorithm to read three numbers then display the largest.

Start

Large number = 0

Get number = 1

If number 1 > Ln

Ln > number 1

End if

Get number = 2

If number 2 > Ln

Ln > number 2

End if

If number 3 > Ln

Ln = number 3

End if

stop

6. Write an algorithm to read 100 numbers then display the largest.

Start

Ln = 0

For ( i = 1, 100, i++ )

Get number

If number > Ln

Ln = number

End for

Display Ln

end

Start

Sum = 0, count = 0
Read a number

Count =Count + 1, Sum = Sum + number

If(I=1, I<=100, I++) then

Display sum

Else go to step 3

End If

Stop

Das könnte Ihnen auch gefallen