Write a program that asks a user to input non-negative integers (numbers that are >=0) until the user enters a negative number (< 0).If odd the user gets 1 point if even user gets 0 points. Output the total number of points If the user the following numbers: 3 -9 Then the points gained is 1+1+0+0 = 2 points since 3 is odd so 1pt, 5 is odd so 1 pt, 0 is even so Opt, 2 is even so 0 pt and program quits since -9 is negative

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question
Write a program that asks a user to input non-negative integers (numbers that are >=0) until the user enters a negative number (< 0).If odd
the user gets 1 point if even user gets 0 points. Output the total number of points
If the user the following numbers:
3
5
2
-9
Then the points gained is 1+1+0+0 = 2 points since 3 is odd so 1pt, 5 is odd so 1 pt, 0 is even so Opt, 2 is even so 0 pt and program quits
since -9 is negative
We make the following assumptions
• O is even number
• no newline after the output
Transcribed Image Text:Write a program that asks a user to input non-negative integers (numbers that are >=0) until the user enters a negative number (< 0).If odd the user gets 1 point if even user gets 0 points. Output the total number of points If the user the following numbers: 3 5 2 -9 Then the points gained is 1+1+0+0 = 2 points since 3 is odd so 1pt, 5 is odd so 1 pt, 0 is even so Opt, 2 is even so 0 pt and program quits since -9 is negative We make the following assumptions • O is even number • no newline after the output
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
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