Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Desafío: Bucle Do-While | Bucles
Quizzes & Challenges
Quizzes
Challenges
/
Fundamentos de C#

bookDesafío: Bucle 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

main.cs

copy
12345678910111213141516171819202122232425
using 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

main.cs

copy
12345678910111213141516171819202122232425
using 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); } } }

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 5

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you show me an example of how the loop would look in code?

What programming language should I use for this task?

Can you explain what should happen when numberA equals numberB?

bookDesafío: Bucle Do-While

Desliza para mostrar el menú

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

main.cs

copy
12345678910111213141516171819202122232425
using 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

main.cs

copy
12345678910111213141516171819202122232425
using 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); } } }

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 5
some-alt