Q1: Write a program that reads a set of N integers. Then, the program finds and outputs the sum of the even values and the sum of the odd values of them. For example: if the value entered for N=5, and the five integers are 3, 6, 2, 9, 7. Then the sum of even values (6+2 = 8), and the sum of odd values (3+9+7 = 19) Q2: Write a program that reads some numbers until it reaches a specific value (assume -1 is a stop value in this case). The program should find and outputs the average of all of the numbers (between 10...40) except the stop value (-1). For example: If the numbers look like: 12 5 30 48 -1. Then, the average of the numbers: (12+30)/2 = 21.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

14

 

Q1: Write a program that reads a set of N integers. Then,
the program finds and outputs the sum of the even values
and the sum of the odd values of them. For example: if the
value entered for N=5, and the five integers are 3, 6, 2, 9, 7.
Then the sum of even values (6+2 = 8), and the sum of
odd values (3+9+7 = 19)
Q2: Write a program that reads some numbers until it
reaches a specific value (assume -1 is a stop value in this
case). The program should find and outputs the average of
all of the numbers (between 10...40) except the stop value
(-1). For example: If the numbers look like: 12 5 30 48 -1.
Then, the average of the numbers: (12+30)/2 = 21.
Transcribed Image Text:Q1: Write a program that reads a set of N integers. Then, the program finds and outputs the sum of the even values and the sum of the odd values of them. For example: if the value entered for N=5, and the five integers are 3, 6, 2, 9, 7. Then the sum of even values (6+2 = 8), and the sum of odd values (3+9+7 = 19) Q2: Write a program that reads some numbers until it reaches a specific value (assume -1 is a stop value in this case). The program should find and outputs the average of all of the numbers (between 10...40) except the stop value (-1). For example: If the numbers look like: 12 5 30 48 -1. Then, the average of the numbers: (12+30)/2 = 21.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning