Would somebody chck this code please. I am a struggling C++ student and need all the help I can get. Thanks, Curt
Here are the directions:
create a function that check's the number, put's out whether
it's odd or even and adds it to the total variable
#include"stdafx.h"
#include<iostream>
usingnamespace std;
//declare the variable's
int total;
int number_buffer = 1;
bool checker(int number)
{
if(number == 0){return false;}
if(number%2)
{
cout << number << " is odd" << endl;
} else {
cout << number << " is even" << endl;
}
total += number;
}
int main()
{
//request user input
cin >> number_buffer;
//continue to ask input until 0 is entered,
//if 0 is entered does checker return's false, else true.
while(checker(number_buffer)){cin >> number_buffer;}
//show the total
cout << "Total: " << total;
return 0;
}