help please

can someone please tell me what im doing wrong im trying to find total gross for department entered but it keeps giving me a total gross for every department and I don't want that lol I think its maybe just one word im missing but not sure 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
// display record by searching by dept number
void searchByNumber(Staff s[] ,int row)
{
	double GrandTotalPay=0.0;
	clrscr();
	cout << "this is Search\n";

	int deptno;
	cout << "Enter department Number : ";

	Input(deptno);

	for (int r=0;r<row;r++)
	{
		if ( deptno ==  s[r].DeptNo,row )
		
		GrandTotalPay = GrandTotalPay += s[r].Gross ;
			//ShowStaff(s[r],row);
			//pressKey();
		
		
	}cout<< " Total pay for department"<<deptno << " is "<<GrandTotalPay;
	pressKey();
}
if ( deptno == s[r].DeptNo,row )
The comma operator first evaluates the first operand deptno == s[r].DeptNo and discards the result, then the second operarand row is evaluated and this is the value that is returned, so the if statement you have there is equivalent to if ( row ). Probably not what you intended.



thankyou I got it working been trying to figure it out for 2 days now thanks again
Topic archived. No new replies allowed.