I want to only print numbers up to 10 but my program prints it infinte please help i am in confusion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I want to only print numbers up to 10 but my program prints it infinte please help i am in confusion

https://code.sololearn.com/cIvKv6P7cV8E/?ref=app

5th Apr 2020, 6:29 AM
Ajaz Ok
3 Answers
+ 6
The structure of for loop is incorrect. This is what you did : for (i<=10;i++;) Here, the i++ is considered as condition part. You should make the for loop like this : for (;i<=10;i++) as initialization of counter 'i' is done already so keep the initialization part blank.
5th Apr 2020, 6:35 AM
Nova
Nova - avatar
+ 1
Nova thanks
5th Apr 2020, 6:37 AM
Ajaz Ok
+ 1
You should accept Nova's answer with the tick, this gives him XP and lets other's know that is the answer which helped you, and works.
5th Apr 2020, 10:51 PM
inxanedev!
inxanedev! - avatar