Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The assignment contains two parts 1. Even sum. Study hovering. As you work on this project, demonstrate to the lab instructor looking up the value

image text in transcribed
The assignment contains two parts 1. Even sum. Study hovering. As you work on this project, demonstrate to the lab instructor looking up the value of a variable by hovering over it. Create a project titled Lab3_sum with a single file sum. cpp. Your program should ask the user for a sequence of numbers until the user inputs 0 (zero) and then the program should print the sum of even numbers that the user input. Here is an example dialog: Input sequence of integers (zero to stop): 4320104510010 The sum of even numbers is: 86 You are not allowed to use functions, arrays or other constructs that we have not yet studied. Hint: You need to use iterate-and-keep-track idiom. while or do-while would be a good construct to use. Consider a single number in each iteration. In the while-expression check if this number is not zero. If not -- proceed, if yes -- stop evaluation and print out the result. Declare a variable where your program will collect the sum. Make sure to initialize this variable. In the loop, with an if, check if the number is even and, if yes, add it to the sum. Look at this_example of selecting the maximum number. It is very similar to what you need to implement. Also, integer division or the remainder operator are quite helpful

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions