need help with my function call void

pretty much when i try to call the function it says that gross and prov is invalid please need help with this so much been trying to figure it out for hours now
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
  #include<iostream>
using namespace std;


void n(int,int);
	



int main()
{
	int N;
	cout << "press N" << endl;
	cin>>N;
	
	char salary;

		switch (salary) {
		case 'N':
			cout << "more information about salary: " << endl;
				break;
				n(prov,gross);
		default:
			cout <<"press anything to exit" << endl;
				break;
		}

		cout << "the gross salary is" << salary << endl;


		
	return 0;
	system("pause");

}


void n(int gross, int prov)

{

	cout << "enter gross" << endl;
	cout<< gross;

	cout << "enter how much u get in the prov" << endl;
	cout<< prov;

	prov = gross*prov;

	cout << "Gross Salary is:   " << endl;
	cout<< gross;

	cout << "prov salary is:   " << endl;
	cout<< prov;




	
	system("pause");
}
In main you don't have variables called gross and prov. Unfortunately, the compiler can't read your mind to find out what you intended those arguments to be, so it flags it as an error.

It also looks like you're using an uninitialized variable salary which will result in undefined behavior when you finally get your code compiling as well as asking the user to type a letter that you're trying to stuff into an int variable which will cause the stream to enter an error state.
Last edited on
This kind of errors are very common and it's important to keep practicing in order to solve them. If you'll practice more, you'll get better, which will make them less common and easier to be detected. There are programs that helps with it sometimes, like checkmarx and many others, but I always recommend on practicing and understanding the language as much as possible in order to achieve greatness.
Good luck.
Topic archived. No new replies allowed.