#include <iostream>
usingnamespace std;
//**************** main function ****************************
void main()
{
cout << "This program count how many negative numbers you enter. \nThere will be three sections. \nEnter 0 to end a section." <<endl<<endl;
for (int i=0; i<3; i++)
{
cout << "\n************ SECTION " << i+1 << "**************"<<endl;
cout << "\nYou have entered " << getInput() << " negative numbers so far."<<endl;
cout << "**************************"<<endl<<endl;
}
return;
}
//***************** count function *********************
int getInput()
{
double number; //hold number entered by the user
count=0;
//get input
do
{
cout << "Enter a number: ";
cin >> number;
//count positive number
if (number < 0)
count ++;
} while (number !=0);
//return counting result
return count;
}
Try doing int main(int argc, char **argv) instead of void main() and then change return; to return 0;
And you will also need a function prototype: int getInput();
This is because you define the function after main and main does not "know" about it. So just put that prototype somewhere at the top of your file above int main.
The prototype allows you to define the function after main.
thanks I missed that, I don't what else is wrong it still wont compile
You know, your compiler will be outputting handy error messages to explain to you what the errors are, and on which lines they occur.
If the people who wrote your compiler decided that it would be helpful for it to tell you that information, what made you decide that it wouldn't be helpful to tell us the same information?