can you help why wont this compile?

ok ive tryed everything and read the error code and i dont get it could you help me ok heres my code

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// old test.cpp : main project file.

#include "stdafx.h"
#include <iostream>
using namespace std;

Findage(unsigned momage - unsigned urage)

int main()
{

	unsigned age;
	unsigned momage;
	unsigned urage;
	unsigned total;

	cout << "how old are you?\n";
	cout << ":";
	cin >> age;

	if (age > 30)

		cout << "wow your soo old!\n";

	if (age < 18)

		cout << "wow your young\n";

	if (age > 18)

		cout << "wow if your a female i want to tap you =)";

	cout << "okay now lets subtract ages from ur mom";
	cin >> momage;

	cout << "how old are you?";
	cin >> urage;


	total = Findage(momage, - urage)

	cin.get();
	cin.get();
	return 0;
}

Findage(unsigned momage, - unsigned urage) 

{
	cin.get();

	unsigned momage, - unsigned urage;

	
}



ERROR CODE:

------ Build started: Project: old test, Configuration: Debug Win32 ------
old test.cpp
old test.cpp(7): error C2143: syntax error : missing ',' before '-'
old test.cpp(9): error C2144: syntax error : 'int' should be preceded by ';'
old test.cpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
old test.cpp(40): warning C4146: unary minus operator applied to unsigned type, result still unsigned
old test.cpp(40): error C2660: 'Findage' : function does not take 2 arguments
old test.cpp(42): error C2146: syntax error : missing ';' before identifier 'cin'
old test.cpp(47): error C2059: syntax error : '-'
old test.cpp(49): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
old test.cpp(52): error C2082: redefinition of formal parameter 'momage'
old test.cpp(52): error C2059: syntax error : '-'
old test.cpp(55): warning C4508: 'Findage' : function should return a value; 'void' return type assumed
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using namespace std;

int Findage(unsigned int momage , unsigned int urage);
//Missing Coma and Semicolon and Function type

int main()
{

	unsigned int age = 0;
	unsigned int momage = 0;
	unsigned int urage = 0;
	unsigned int total = 0;
	//Good to initialize variables at declaration

	cout << "how old are you?\n";
	cout << ":";
	cin >> age;

	if (age > 30)

		cout << "wow your soo old!\n";

	if (age < 18)

		cout << "wow your young\n";

	if (age > 18 && age < 30) //If age is greater than 30 then it will display "wow if your a female i want to tap you =) " and "wow your soo old!"

		cout << "wow if your a female i want to tap you =) ";

	cout << "okay now lets subtract ages from ur mom ";
	cin >> momage;

	cout << "how old are you? ";
	cin >> urage;


	total = Findage(momage, urage);

	//Missing Semicolon 

	cout << total << " years apart." << endl;

	//Display Result

	cin.sync ();

	//Synchronize Buffer

	cout << "Press ENTER to end the program." << endl;

	//Prompt User to press ENTER

	cin.get();

	return 0;
}

int Findage(unsigned int momage , unsigned int urage) 
{
	int Temp = 0;
	//Why cin.get ()?
	Temp = momage - urage;
	return Temp;
}
//Missing Function type and comma 

Last edited on
THANK YOU! now i know to declare my own functions and now im a better programmer thank you!
Topic archived. No new replies allowed.