Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: for Loop | Loopar
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C#-Grunder

bookChallenge: for Loop

Uppgift

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 allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 3
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: for Loop

Svep för att visa menyn

Uppgift

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 desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 3
single

single

some-alt