Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: break and continue | Bucles
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Fundamentos de C#

bookChallenge: break and continue

Tarea

Swipe to start coding

In this task, you will practice using break and continue statements in a for loop with a simple scenario.

  • Initialize a variable total to 0 to store the sum of processed numbers.
  • Use a for loop to count numbers from 1 up to 10.
  • Inside the loop:
    • Use i % 4 == 0 to check if a number is divisible by 4.
    • Use continue to skip numbers divisible by 4.
    • Use break to stop the loop when a number is greater than 8.
    • Update total with total = total + i.
  • Print each processed number with Console.WriteLine("Number: " + i).
  • Print the final sum with Console.WriteLine("Total sum: " + total).

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 11
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

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

close

bookChallenge: break and continue

Desliza para mostrar el menú

Tarea

Swipe to start coding

In this task, you will practice using break and continue statements in a for loop with a simple scenario.

  • Initialize a variable total to 0 to store the sum of processed numbers.
  • Use a for loop to count numbers from 1 up to 10.
  • Inside the loop:
    • Use i % 4 == 0 to check if a number is divisible by 4.
    • Use continue to skip numbers divisible by 4.
    • Use break to stop the loop when a number is greater than 8.
    • Update total with total = total + i.
  • Print each processed number with Console.WriteLine("Number: " + i).
  • Print the final sum with Console.WriteLine("Total sum: " + total).

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 11
single

single

some-alt