0
How to make ~case age>20:statement~ can be activated
Here is the code http://www.sololearn.com/app/cplusplus/playground/cMVEOlcOVwle/
7 Answers
0
Maybe I write wrong thing
0
#include<iostream>
using namespace std;
int main(){
string age = "age \> 20";//outputs litteraly
cout << age;
}
or replace by:
int age = 21;
cout << (age>20) << endl;
and you'll get 1 which is same as a "true"...
0
int age;
cin >> age;
if(age>20){
cout<<"You aren't old..."<<endl;
}
you don't need return 0... compiler knows...
0
in your case of a switch statement, you just need to put age>20 in parentheses in order to work...
0
Thanks! return 0 is just come with program it's really annoying >:), anyway.sooo switch isnt suppose right?
0
in switch, cases must be a constants, expressions with a fixed value... age>20 is not a constant...
0
Thx very much :)