The switch statement
Dear All.
I'm a beginner who want to learn c++. I've ERROR message when I try to run the switch statement below, Really need you help guys. Thanks
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main ()
{
int choice(0); //store selection value here
cout << endl
<< "Please select the number below to load data to the variable\n\n"<< endl
<< endl << "1 mean"
<< endl << "2 Std"
<< endl << "3 Mode"
<< endl << "4 Middle"
<< endl << "5 Min"
<< endl << "6 Max"
<< endl << endl << "Enter your selection number :"; cin >> choice;
switch (choice)
{
case 1: cout << endl << "a" << endl;
break;
case 2: cout << endl << "b" << endl;
break;
case 3: cout << endl << "c" << endl;
break;
case 4: cout << endl << "d" << endl;
break;
case 5: cout << endl << "e" << endl;
break;
case 6: cout << endl << "f" << endl;
break;
default: cout << endl <<"You try enter a wrong number" << endl;
}
return 0;
}
|