- 1

why error happen in this program?

#include<iostream> //#include<conio.h> using namespace std; int main() { int x ; for ( x = 1; x <= 10; x++); { if(x==5) break; cout<< x << " " ; } cout<< endl; return 0; }

25th Jul 2020, 9:05 PM
Shafiq Almatari
Shafiq Almatari - avatar
4 Respuestas
+ 4
You got a semicolon after your loop-definition, so it has no body...
25th Jul 2020, 9:13 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Thanks
26th Jul 2020, 5:39 PM
Shafiq Almatari
Shafiq Almatari - avatar
0
Remove the semicolon comes last of the ' for ' statement. So use for (x = 1; x <= 10; x++) //Not like this for (x = 1; x <= 10; x++);
26th Jul 2020, 1:54 AM
Abijith . U
Abijith . U - avatar
0
very simple code Remove the semicolon comes last of the ' for ' statement. So use for (x = 1; x <= 10; x++) //Not like this for (x = 1; x <= 10; x++);
14th Nov 2021, 8:36 PM
محمد السالمي
محمد السالمي - avatar