Q&A Discussions
why does this code output that there is an error because the else statement doesn't have a corresponding if statement?. How do i correct this?
#include <iostream>
using namespace std;
int main() {
int a;
for (int x =0; x<5;x++){
cin>>a;
if (a<1){
cout<<"a cannot be less than 1\n";
}
else if (a>10){
cout <<"a cannot be greater than 10\n";
}
}
else{
cout<<"code can run now"<<endl;
}
return 0;
}
3 Votes
8 AnswersJava data types vs. JS
12 Votes
1 AnswerHow to achive this task
2 Votes
1 AnswerPlz explain output?
0 Votes
2 AnswersIndexers Questions
3 Votes
2 AnswersMeaning of "int total"
1 Vote
2 AnswersPlease help in this code
3 Votes
8 AnswersInteger's digits.
0 Votes
2 AnswersI NEED explaination
14 Votes
12 AnswersC# basic concept problem
0 Votes
3 AnswersHot today
Pig Latin
0 Votes
Someone can help me
0 Votes
Please rate my code from 1 to 10
2 Votes
Square Roots
0 Votes
What's wrong with this?
2 Votes
I’m new someone can help me
0 Votes