Computer Science (CS01)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Computer Science (CS01)

Work Done by: Mohamed Alsan


QUESTIONS:

ANSWERS:
QUESTION 01 Print “Total:”;tt
num(10)←0 Print “Average:”;avg
tt←0 For x = 1 to 10
avg←0 Print “All inputted
For x = 1 to 10 number:”;num(x)
Input “Enter a number”;num(x) Next x
tt = tt + num(x) End
Next x
avg←tt/10

COMPUTER SCIENCE TUITION


QUESTION 02 QUESTION 03
num(10)←0 num(10)←0
pn←0 sp←0
nn←0 sn←0
For x = 1 to 10 For x = 1 to 10
Input “Enter a number”;num(x) Input “Enter a number”;num(x)
If num(x) > 0 then If num(x) > 0 then
pn ← pn + 1 sp ← sp + num(x)
Else Else
nn ← nn + 1 sn ← sn + (num(x))
Endif Endif
Next x Next x
For x = 1 to 5 For x = 6 to 10
Print “First five numbers Print “First five numbers
inputted:”;num(x) inputted:”;num(x)
Next x Next x
Print “Count of positive no.”; pn Print “Sum of positive no.”; sp
Print “Count of negative no.”; nn Print “Sum of negative no.”; sn
End End

COMPUTER SCIENCE TUITION


QUESTION 04 QUESTION 05
num(10)←0 num(10)←0
cnton, cnten ←0 tton←0
on(x), en(x)←0 tten←0
For x = 1 to 10 on(x)←0
Input “Enter a number”;num(x) en(x)←0
If num(x) MOD 2 = 0 then For x = 1 to 10
en(x) ← num(x) Input “Enter a number”;num(x)
cnten ← cnten +1 If num(x) MOD 2 = 0 then
Else en(x) ← num(x)
on(x) ← num(x) tten ← tten + num(x)
cnton = cnton +1 Else
Endif on(x) ← num(x)
Next x tton = tton + num(x)
For x = 1 to 10 Endif
Print “Odd number(s):”;on(x) Next x
Print “Even number(s):”;en(x) Print “Sum of Odd no.(s):”;tton
Next x Print “Sum of Even no.(s):”;tten
For x = 1 to 10 For x = 1 to 10
For i = 10 to 10 - x For i = 10 to 10 - x
If en(x) < en (i+1) If on(x) > on (i+1)
temp ← en(x) temp ← on(x)
en(x) ← en(i+1) on(x) ← num(i+1)
en(i+1) ← temp on(i+1) ← temp
Next Next
Next Next
For x = 1 to 10 For x = 1 to 10
Print en(x) Print on(x)
Next x Next x
End End

COMPUTER SCIENCE TUITION


QUESTION 06 QUESTION 07
num(10)←0 num(10)←0
big←-999999 big←-999999
small←999999 small←999999
For x = 1 to 10 For x = 1 to 10
Input “Enter a number”;num(x) Input “Enter a number”;num(x)
If num(x) > big then If num(x) > big then
big ← num(x) big ← num(x)
Endif Endif
If num(x) < small then If num(x) < small then
small ← num(x) small ← num(x)
Endif Endif
Next x Next x
For x = 10 to 1 STEP -1 For x = 10 to 6 STEP -1
Print “Number in reversed Print “Last 5 number in reversed
order:”;num(x) order:”;num(x)
Next x Next x
Print “Biggest number;”; big Print “Biggest number;”; big
Print “Smallest number;”; small Print “Smallest number;”; small
End End

COMPUTER SCIENCE TUITION

You might also like