what is wrong with my code here?
int main() {
for(int i=0; i>=5; ++i){
cout << "Hello World! \n";
}
return 0;
}
It is supposed to display "Hello World" 5 times.
All you need to do is replace the >=
with <=
because you are saying that i
is greater than 5 already. Also, with this for loop it will display "Hello World" 6 times because you have i
starting at 0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.