I've been doing too much basic. I can only remember the Basic syntax for Select Case. What is the right way in C++?
I need better memorizational skills ;)
Printable View
I've been doing too much basic. I can only remember the Basic syntax for Select Case. What is the right way in C++?
I need better memorizational skills ;)
Try the switch statement.
Code:int nAge;
cout << "Enter your Age";
cin >> nAge;
switch( nAge )
{
case 20:
cout << "Your are the same age as me";
break;
case 90:
cout << "You are older than my grandpa";
break;
case 50:
cout << "You are about the same as my parents";
break;
}
Use case default: for anything that doesn't fit the others.
Perfect. Thanks guys :)