hi there everyone~~ please check my error :)

hi there i can't seem to find my error :( i've put my error at the bottom of the code. btw this is my first post:)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;

{			
int zero_both(int n1, int n2) ; //get loan balance
}

int main()
{
		int price, down_payment;
		  cout << "Please enter the price amount: \n";
		  cin  >> price ;
  		  cout << "Please enter the down payment: \n";
		  cin  >> down_payment ;
		int loan_balance = zero_both(int n1, int n2); 		
				
return 0;
}
//function call
int zero_both(int n1, int n2)  //n1 = price, n2 = down payment
{ 
	//n3 = loan_balance
	int n3 = n1 - n2 ;
	return n3;
		
}


chap4pp8.cpp:14:1: error: expected unqualified-id before ‘{’ token
{
^
chap4pp8.cpp: In function ‘int main()’:
chap4pp8.cpp:27:32: error: expected primary-expression before ‘int’
int loan_balance = zero_both(int n1, int n2); //zero_both(price, down_payment);
^
chap4pp8.cpp:27:40: error: expected primary-expression before ‘int’
int loan_balance = zero_both(int n1, int n2); //zero_both(price, down_payment);
^
chap4pp8.cpp:27:46: error: ‘zero_both’ was not declared in this scope
int loan_balance = zero_both(int n1, int n2); //zero_both(price, down_payment);
Remove the curly brackets around the function declaration.
First of all thanks peter87! i've removed the braces and received another error. i can't believe i didn't see those braces!

chap4pp8.cpp: In function ‘int main()’:
chap4pp8.cpp:25:32: error: expected primary-expression before ‘int’
int loan_balance = zero_both(int n1, int n2); //zero_both(price, down_payment);
^
chap4pp8.cpp:25:40: error: expected primary-expression before ‘int’
int loan_balance = zero_both(int n1, int n2); //zero_both(price, down_payment);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace std;

{ <-- REMOVE THIS LINE
int zero_both(int n1, int n2) ; //get loan balance
} <-- REMOVE THIS LINE

int main()
{
		int price, down_payment;
		  cout << "Please enter the price amount: \n";
		  cin  >> price ;
  		  cout << "Please enter the down payment: \n";
		  cin  >> down_payment ;
		int loan_balance = zero_both(int n1, int n2); <- REMOVE the int in the parameter list

return 0;
}
//function call
int zero_both(int n1, int n2)  //n1 = price, n2 = down payment
{ 
	//n3 = loan_balance
	int n3 = n1 - n2 ;
	return n3;
}
thank you kbw! really appreciate the help! been up till 2am.
line 15 - do you mean to send price and down_payment that have just been entered instead of n1, n2?
Topic archived. No new replies allowed.