+ 3

Could anyone tell me what is wrong with the piece of code below?it always gives me errors i wanna print if someone can vote.

#include <iostream> using namespace std; //even if you are above 18 but not a citizen..you cant Vote// int main() { const int LEGAL=18; bool isCitizen=true; int age; cout<<"enter your age"<<endl; cin>>age; if(age>=LEGAL && isCitizen){ cout<<"u can vote as u are a citizen"<<endl; else cout<<"opps since u are not a citizen you cannot vote"<<endl;} else{ cout<<"you cannot vote since your age is illegal"<<endl; } return 0; }

8th Sep 2017, 11:49 AM
RiGeL
RiGeL - avatar
1 Antwort
+ 2
Indent your code and your mistake will becomes obvious... Fixed (and indented code): https://code.sololearn.com/c2OGliH3N7Hb/?ref=app
8th Sep 2017, 1:05 PM
visph
visph - avatar