Collect and output statistics using constructs

Hi everyone!

I am completely new to C++ programming and am having some difficulties structuring the code for the assignment below. The code I have so far is listed below that again. I'm confused about how to declare the value(s) that will be input by user n times. I'm also not sure what constructs to use to output the statistics listed at bottom of the assignment. ANY assistance whatsoever is highly appreciated.

Write a program that generates some basic statistics on a set of input values. The program begins by first prompting the user to specify the number of values, say n, that are to be processed. Once this value has been determined program should prompt the user to enter n values, with one prompt per value to be entered.

For each of the n values entered, the program should perform the following actions (without performing any additional output per value:
• Maintain a running total value
• Determine if the value is negative
• Determine if the value is an integer
• If the value is an integer, determine whether it is even or odd

After all of the values have been input to the program, the program should then output the following statistics concerning the input:
• The number of values entered
• The sum of the values entered
• The average of the values entered
• The number of negative values entered
• The number of even values entered
• The number of odd values entered

include <iostream> 
using namespace std; 

int main() 
int loopCount;
cout << “Specify number of values to process: “;
cin >> loopCount;

while (loopCount-- > 0)
cout << “Enter next value:  \n”;
cin >> 
For start write the program counting running total and printing the sum at the end. Add some variable "sum" before loop and add any entered value to it.

I think you will then see how to do the rest.

Not the code you pasted is incomplete, it ends abruptly at the middle of the loop.
Last edited on
Hi rodiongork,

Thanks so much for the reply! I'm a little confused as to how I should structure the code for counting a running total. Should I add/declare the variable int sum; before int loopCount; in my current code? And where in the code should I put the expression that counts the running total? These might be really stupid questions but this is so new to me that it doesn't come natural yet. I appreciate all help!
Topic archived. No new replies allowed.