Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: break and continue | Laços de Repetição
Fundamentos de C#

bookChallenge: break and continue

Tarefa

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).

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 11
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: break and continue

Deslize para mostrar o menu

Tarefa

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).

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 11
single

single

some-alt