An algorithm read numbers between 0and 15 and check whether number is even or odd then display sum of even numbers and average of odd numbers
Start
Declare Integer number
Declare Integer sum
Declare Real average
Declare Integer sumOdd
Declare Integer counterOdd
Set sum =0
Set sumOdd=0
for i =0 to 15
Dispay "Enter number [0-15]: "
Read number
if number mod 2 =0
sum= sum+number
else
sumOdd=sumOdd+number
counterOdd=counterOdd+1
end if
End for
average=sumOdd/counterOdd
Display "Sum: ",sum
Display "Average of odd numbers: ",average
Stop
Comments
Leave a comment