Hi. I am writing a program to read user input numbers until '0' is entered. I then figure out if each number is even or odd and find the average of all the evens and all the odds (even average is one number, odd average is another.) I have it running where I count the evens and odds, but don't know how to add and average the two groups. Can someone explain how to do this? Thanks so much in advance. Here is my code so far.
#include <iostream>
using namespace std;
int even=0;
int odd=0;
int number=0;
int main()
{
int i=0; //holds the index for our loop.
int input=0;
//int lowest = 0; //holds the lowest number.
//int highest = 0; //holds the highest number.
int eventotal = 0;
int oddtotal = 0;
do
{
cout << "Please enter a number: "<< endl;
cin >> number;
if ( (number%2 == 0) && (number > 0) )
even++;
else if (number > 0)
odd++;
}
while (number!=0);
cout << "You have entered" << ' '<< odd << ' ' <<"odd numbers." << endl;
cout << "And" << ' ' << even << ' ' <<"even numbers." << endl;
/*cout << "Average: " << total/input << "." << endl;
cout << "lowest: " << lowest << " highest: " << highest << "." << endl; */
return 0;}