Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: for Loop | Løkker
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Grundlæggende

bookChallenge: for Loop

Opgave

Swipe to start coding

Imagine you are buying several items in a shop. Each item costs the same amount, and you want to calculate the total cost of all items.

  • Initialize totalCost to 0.
  • The loop should start with i = 0 and run while i < quantity.
  • Add itemPrice to totalCost inside the loop.
  • Return totalCost at the end of the method.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: for Loop

Stryg for at vise menuen

Opgave

Swipe to start coding

Imagine you are buying several items in a shop. Each item costs the same amount, and you want to calculate the total cost of all items.

  • Initialize totalCost to 0.
  • The loop should start with i = 0 and run while i < quantity.
  • Add itemPrice to totalCost inside the loop.
  • Return totalCost at the end of the method.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 3
single

single

some-alt