expected initializer error before the + token

I am getting a error here I am passing the x y z from other functions. Now I am trying to add those together and store it as t. I get a compiler error
"expected initializer before the + token".

1
2
3
4
5
6
7
8
9
10
11
int Caltotal (int& q)
{
    int x,y,z,t;


    breakfast(x);
    lunch(y);
    dinner(z);
x+y+z =  t ; //error here 
cout << "Your total for today is."<<t<< ;
}


I also would like some advice as how to proceed. I want to run this 7 times and then calculate the total. I also plan on putting if statements in this program to send a good message if I am under a certain calorie number, and a encouraging number if I am over. Is this when I would run a loop?This isn't homework I am trying to write this as a personal project.I just want to take this as far as I can to learn.
Syntax mistake. Try t = x + y + z;.
Last edited on
Topic archived. No new replies allowed.