In: Computer Science
Example: let the inputs are: 3, 0, -1, 0, 9, -5, 6, 0, 2, 1 then 157 is displayed, because: SS=32+02+(-1)2+02+92+(-5)2+62+02+22+12=157
For example if the user enters B
a
b
e
c
o
o
d
i
u
g
o
a
l
$
Then we have the output below:
#A=2
#E=1
#I=1
#O=3
#U=2
Take ten different numbers as input and display the sum of there squares (SS).
Function Main
Declare Integer sum
Declare Integer a
For i = 0 to 9
Input a
Assign sum =
sum+(a*a)
End
Output sum
End
Take input character from the user unless he enters '$'. Thereafter display how may vowels were entered by the user. Also display the number of each vowel ('a', 'e', 'i', 'o' and 'u') separately.
Function Main
Declare Integer Array Vowels[5]
Declare String a
While a!="$"
Input a
If a=="A" ||
a=="a"
Assign Vowels[0] = Vowels[0]+1
End
If a=="E" ||
a=="e"
Assign Vowels[1] = Vowels[1]+1
End
If a=="I" ||
a=="i"
Assign Vowels[2] = Vowels[2]+1
End
If a=="O" ||
a=="o"
Assign Vowels[0] = Vowels[0]+1
End
If a=="U" ||
a=="u"
Assign Vowels[0] = Vowels[0]+1
End
End
Output "#A" = Vowels[0]
Output "#E" = Vowels[1]
Output "#I" = Vowels[2]
Output "#O" = Vowels[3]
Output "#U" = Vowels[4]
End