• Log in or sign up for an account here: https://www.sythe.org/login

Help with a program

FreakNasty188

Active Member
Joined
Jul 15, 2011
Sythe Gold
0
Messages
174
Hey guys I'm writing a basic C++ program for my programming class. Basically the user inputs their numerical birth month and it tells them what season they were born in. I have the code written, but I'm getting these errors.


Error 1 error C2660: 'season' : function does not take 1 arguments c:\users\kevin\desktop\cmpsc101\10_4_11\10_4_11\p1.cpp 20

And


Error 2 error C2447: '{' : missing function header (old-style formal list?) c:\users\kevin\desktop\cmpsc101\10_4_11\10_4_11\p1.cpp 24

And


3 IntelliSense: expected a declaration c:\users\kevin\desktop\cmpsc101\10_4_11\10_4_11\p1.cpp 24

Here's my program:

#include <iostream>
using namespace std;

void birthMonth();
void season();

int main()
{
birthMonth();

return 0;
}

void birthMonth()
{
int month;
cout << "Enter your numerical birth month: ";
cin >> month;

season(month);
}

void season (int month);
{
if (month < 1)
cout << "Invalid birth month";
else if (month <= 3)
cout << "Your birth month is in the Winter.";
else if (month <= 6)
cout << "Your birth month is in the Spring.";
else if (month <= 9)
cout << "Your birth month is in the Summer.";
else if (month <= 12)
cout << "Your birth month is in the Fall.";
else
cout << "Invalid birth month";
}

Anyone think they can help?
 
In your prototype definitions for the functions you forgot to specify that the function season takes an integer as a parameter.

The header should look like this:
Code:
#include <iostream>
using namespace std;

void birthMonth();
void season(int);
 
Ok thanks that got rid of one of the errors, but I'm getting these 2 still:


Error 1 error C2447: '{' : missing function header (old-style formal list?) c:\users\kevin\desktop\cmpsc101\10_4_11\10_4_11\p1.cpp 24

And


2 IntelliSense: expected a declaration c:\users\kevin\desktop\cmpsc101\10_4_11\10_4_11\p1.cpp 24

Any ideas?
 
On line 23 you have a semi colon at the end of your function delcaration, you don't need it there.

Code:
void season (int month);
{
	if (month < 1)
		cout << "Invalid birth month";
	else if (month <= 3)...

^seen there on the first line, needs to be removed.
 
Thanks so much man! I feel stupid now lol they were stupid mistakes. Thanks though!
 
duelarena.gg
Back
Top