Function prototype errors

Here's the source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
int milpergal(int);
using namespace std;
int miles, gallons;

int main()
{
	cout << "How many miles you travelled?: ";
	cin >> miles;
	cout << "How many gallons you burned?: ";
	cin >> gallons;
	cout << milpergal(int) << " miles/gallon.";
	cin.get();
	cin.get();
	return 0;
}
int milpergal(n int)
{
	n = miles / gallons;
	return n;
}


Here's the errors:

1>------ Build started: Project: pg131ex999, Configuration: Debug Win32 ------
1>Compiling...
1>source.cpp
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(14) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(14) : error C2660: 'milpergal' : function does not take 0 arguments
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(14) : error C2059: syntax error : ')'
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(19) : error C2065: 'n' : undeclared identifier
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(19) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(19) : error C2448: 'milpergal' : function-style initializer appears to be a function definition
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(19) : error C2059: syntax error : ')'
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(20) : warning C4091: '' : ignored on left of 'int' when no variable is declared
1>c:\documents and settings\x\my documents\visual studio 2008\projects\pg131ex999\pg131ex999\source.cpp(20) : error C2143: syntax error : missing ';' before '{'
1>Build log was saved at "file://c:\Documents and Settings\x\My Documents\Visual Studio 2008\Projects\pg131ex999\pg131ex999\Debug\BuildLog.htm"
1>pg131ex999 - 8 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I don't understand what I did wrong. It seems to whine about the function's prototype, but I checked the Internet and it seems that I declared it properly.

Basically the program asks for miles and gallons from the user, and then it shows what is the mileage of the car.
 
	cout << milpergal(int) << " miles/gallon.";


You have to pass a variable to milpergal. int is a type.

 
int milpergal(n int)


you mean

int n

not

n int
Thanks, errors have dissapeared.

But how would you pass multiple arguments to the milpergal function?
Topic archived. No new replies allowed.