I can't find anything wrong!

I'm having trouble fixing the following errors:

5_4.cpp: In function âint main()â:
5_4.cpp:21:4: error: invalid operands of types âintâ and âconst char [5]â to binary âoperator<<â
<< "for " << numseller++ << " girlscouts" << endl;
^
5_4.cpp:26:4: warning: left shift count >= width of type
<< '.' << endl;
^
5_4.cpp:26:11: error: invalid operands of types âintâ and â<unresolved overloaded function type>â to binary âoperator<<â
<< '.' << endl;
^
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
// Lab 5 cookies.cpp
#include <iostream>
#include <string>
using namespace std;
int main()
{
int numboxes, totalboxes, numseller;
double averageboxes;

totalboxes = 0;
numseller = 1;

cout << "             **** Cookie Sales Information **** \n\n";

cout << "Enter number of boxes cookies sold by seller " << numseller << "(or -1 to quit): ";
cin >> numboxes;
while (numboxes != -1)
{
cout << "Your total number of boxes sold so far is " << totalboxes = totalboxes + numboxes 
<< "for " << numseller++ << " girlscouts" << endl;
cout << "How many boxes were sold by seller " << numseller << "?(or -1 to quit): ";
cin >> numboxes;
}
cout << "The total number of sellers were " << numseller -= 1 
<< '.' << endl;
if (numseller == 0)
cout << "\nNo boxes were sold.\n";
else 
{
averageboxes = totalboxes/numseller;
cout << "The average boxes sold for " << numseller << " sellers was: " << averageboxes << '.' << endl;
}
return 0;
}
Last edited on
cout << "Your total number of boxes sold so far is " << totalboxes = totalboxes + numboxes << "for " << numseller++ << " girlscouts" << endl;
Is parsed as:
( cout << "Your total number of boxes sold so far is " << totalboxes ) = ( totalboxes + numboxes << "for " << numseller++ << " girlscouts" << endl );
See the problem?
Use parenteses and mind operator priority next time
I added parentheses to that statement and the numseller -= part, it works now thank you!!!
Topic archived. No new replies allowed.