0

C++ Beverage While

My code isn't working properly. What am i doing wrong? We were asked only to declare int beverage, and we must use a while loop. #include <iostream> #include <iomanip> using namespace std; int main() { int beverage; cout << "Please enter the choice of drink" << " (a number from 1 to 4 or 0 to quit)" <<endl; cout << "Hot Beverage Menu" << endl << endl; cout << "1: Coffee" << endl; cout << "2: Tea" << endl; cout << "3: Hot Chocolate" << endl; cout << "4: Cappuccino" << endl; cout << "0: QUIT" << endl << endl << endl; cin >> beverage; while(beverage >4 || beverage <0); { cout << "Invalid choice - Please re-enter "; cin >> beverage; } cout << "You have selected option number " << beverage; return 0; }

26th Aug 2017, 4:14 PM
gorgamin
gorgamin - avatar
2 odpowiedzi
+ 1
You should not put ; after while loop correct syntax is : while(expression) { statements ; }
26th Aug 2017, 4:22 PM
Vishesh
0
If I don't, CodeBlocks doesn't run the code.
26th Aug 2017, 7:18 PM
gorgamin
gorgamin - avatar