0

How to make a program that counting 1-100 using for loops?

it need to have a table like for example 1-10 then another column 11-20 until 100

30th Aug 2018, 8:54 AM
Arian Mijares
Arian Mijares - avatar
1 ответ
+ 2
C# : for(int i = 1; i <= 100; i++){ Console.WriteLine(i); } JavaScript : for (var i = 0; i <= 100; i++) { document.write(i + "<br>"); } And look at for loops for the langage you want to be playing with :) For your step 10 by 10 (example in C#) : step = 10; for(int i = 1; i <= step; i++){ if(i % 10 == 0 && step != 100){ step += 10; } Console.WriteLine(i); } Here, in your loop, if your number is a multiple of 10, we add 10 to the max number and check it is less than a 100. You can play with modulos as you want, add loops where you want etc. Be more precise if you need more informations. Enjoy :)
30th Aug 2018, 9:04 AM
Sam Pache
Sam Pache - avatar