Sfida: Ciclo Do-While
You have two variables: numberA and numberB. The program should iterate, adjusting numberA until it reaches numberB.
If numberA is greater than numberB, then numberA should be decremented at each step. If numberA is less than numberB, then numberA should be incremented at each step.
Additionally, write the appropriate condition to terminate the loop.
main.cs
12345678910111213141516171819202122232425using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int numberA = 10; int numberB = 1; do { if (___) { numberA--; } else if (___) { numberA++; } Console.WriteLine(numberA); } while (___); } } }
The loop should continue as long as the numbers are NOT equal (!=).
main.cs
12345678910111213141516171819202122232425using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int numberA = 10; int numberB = 1; do { if (numberA > numberB) { numberA--; } else if (numberA < numberB) { numberA++; } Console.WriteLine(numberA); } while (numberA != numberB); } } }
Grazie per i tuoi commenti!
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Awesome!
Completion rate improved to 1.59
Sfida: Ciclo Do-While
Scorri per mostrare il menu
You have two variables: numberA and numberB. The program should iterate, adjusting numberA until it reaches numberB.
If numberA is greater than numberB, then numberA should be decremented at each step. If numberA is less than numberB, then numberA should be incremented at each step.
Additionally, write the appropriate condition to terminate the loop.
main.cs
12345678910111213141516171819202122232425using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int numberA = 10; int numberB = 1; do { if (___) { numberA--; } else if (___) { numberA++; } Console.WriteLine(numberA); } while (___); } } }
The loop should continue as long as the numbers are NOT equal (!=).
main.cs
12345678910111213141516171819202122232425using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int numberA = 10; int numberB = 1; do { if (numberA > numberB) { numberA--; } else if (numberA < numberB) { numberA++; } Console.WriteLine(numberA); } while (numberA != numberB); } } }
Grazie per i tuoi commenti!