Quiz3 cs104 C Solutions
Quiz3 cs104 C Solutions
Student Number:
CS 104 – Spring 2022
QUIZ 3
1. (50pts) Write a program that finds the sum of a set of numbers, and how
many of the values in the set are odd numbers. The program should
prompt for the number of elements in the set; and then it should prompt
for each number in the set from a user (you need to use input() function to
get them from the user). The program should print out the sum and
number of odd values in the set as an output. (Hint: odd numbers have a
remainder of 1 when divided by 2; and you can use if statement to check
whether the number is odd, or not).
numOfElements = int( input("How many numbers are there in the set? "))
sum = 0
countOddNums = 0
mystery(3,4,5) # a
mystery(5,4,3) # b
mystery(5,3,4) # c
mystery(3,5,4) # d
mystery(4,3,5) # e
a)
x = 3 z = 5
b)
y = 4 x = 5
z = 3 y = 4
c)
y = 3 x = 5
x = 5 y = 3 z = 4
d)
z = 4 y = 5
e)
y = 3 x = 4
x = 4 z = 5