C
C#13mo ago
Richards

✅ loop do while

static void Main(string[] args) { int number; Console.WriteLine("Ievadiet skaitli R:"); number = Convert.ToInt32(Console.ReadLine()); int cipars = number; int skaitlis; Console.WriteLine("Ievadiet pirmo skaitli:"); skaitlis = Convert.ToInt32(Console.ReadLine()); do { Console.WriteLine("Reiz[" + number + "] = "); number++; } while (number<=cipars); } So i have to do loop which starts from 0 to number i entered, for example i enter 6 it should print 0 1 2 3 4 5 6, but i either get it so it starts from 6 or, it goes endlessly, anyone knows what to write in the while section so that it starts from 0 till the number entered
4 Replies
SinFluxx
SinFluxx13mo ago
well your number is what you want to count up to, you need to create a different variable to start from
Teddy
Teddy13mo ago
To expand further. number = Convert.ToInt32(Console.ReadLine()); They enter 6, you've stored 6 to number, so the first number printed is 6
SinFluxx
SinFluxx13mo ago
make sure to reply on the thread you create rather than DM so everyone can see blobthumbsup
Richards
RichardsOP13mo ago
Thanks👌 Thanks<:sregnif_dehcnip:775699449984057364>
Want results from more Discord servers?
Add your server