Discussions Q&R
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 RéponsesWeb-Dev-Kit V-2.0.0
0 Vote
1 Réponsecan someone tell me how to make it impossible for a user to type a 'userchoice1[x]' value that does not range from 1 - 10.
If you also know a way I can make the user input another value for the 'userchoice1[x]' variable if it is less than 1, I'll appreciate you share the knowledge with me.
please see the short code below
1 Vote
2 RéponsesAujourd'hui en vedette
Pig Latin
0 Votes
Someone can help me
0 Votes
Need a friend to study with
0 Votes
Square Roots
0 Votes
What's wrong with this?
2 Votes
I’m new someone can help me
0 Votes
HTML community, HELP!!
1 Votes
I am a super beginner
0 Votes
What's doctype htMl
2 Votes