Challenge: Multi-Dimensional Arrays
Uppgift
Swipe to start coding
A classroom has several rows of students, and each student has a score. You need to calculate the total score for each row using a method that accepts a 2D array.
- Use
array.GetLength(0)to get the number of rows. - Use
array.GetLength(1)to get the number of columns. - Initialize a variable
rowTotal = 0for each row before summing. - Use
rowTotal += scores[row, col]to add each student's score. - Print the row total using
Console.WriteLine.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 4
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 1.25
Challenge: Multi-Dimensional Arrays
Svep för att visa menyn
Uppgift
Swipe to start coding
A classroom has several rows of students, and each student has a score. You need to calculate the total score for each row using a method that accepts a 2D array.
- Use
array.GetLength(0)to get the number of rows. - Use
array.GetLength(1)to get the number of columns. - Initialize a variable
rowTotal = 0for each row before summing. - Use
rowTotal += scores[row, col]to add each student's score. - Print the row total using
Console.WriteLine.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 5. Kapitel 4
single