Hello, i got a problem with this question with my C++ lab reports, i was wondering if anyone could tell me why it isn't working properly, the code is:
Lab Exercise 3a
What output will be produced by the following code when embedded in a complete program?
Consider initial values for first_choice of 0, 1 and -1.
So i made this to figure out the answer:Code:int x = first_choice++; switch (first_choice + x) { case 1: cout << "Waitrose\n" break; case 2: cout << "Sainsburys\n" break; case 3: cout << "Tesco\n" break; case 4: cout << "Asda\n" break; default: cout << "No shopping today!\n"; }
Anyone know why, i get illegal case and illegal break errors.Code:#include "stdafx.h" #include <string> #include <iostream> using namespace std; int main() int x = first_choice++; switch (first_choice + x) { case 1: cout << "Waitrose\n" break; case 2: cout << "Sainsburys\n" break; case 3: cout << "Tesco\n" break; case 4: cout << "Asda\n" break; default: cout << "No shopping today!\n"; } return 0; }
Thanks



LinkBack URL
About LinkBacks



