logo CodeStepByStep logo


Language/Type: C++ basics user input
Related Links:
Author: Marty Stepp (on 2016/06/20)

Write C++ code that prompts the user for nonzero integers, and then prints the average of all even numbers typed. (When the user types 0, stop asking for input.) You may assume that the user types at least one even integer. The following is an example output from one run of your code:

Integer? 1
Integer? 3
Integer? 2
Integer? 6
Integer? 4
Integer? 10
Integer? 9
Integer? 0
Average: 5.5
Type your C++ solution code here:

This problem asks for bare code. Submit a fragment of C++ code as described. Do not write any main function or any function heading around your code; just write the lines of code that will produce the result described.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.