Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Working with the Array | Section
C++ Introduction
セクション 1.  16
single

single

bookChallenge: Working with the Array

メニューを表示するにはスワイプしてください

Reminder how to access an array by index

main.cpp

main.cpp

copy
12345678910
#include <iostream> int main() { int myArray[3] = { 67, 23, 87 }; std::cout << myArray[0] << std::endl; std::cout << myArray[1] << std::endl; std::cout << myArray[2] << std::endl; }

Note

Index counting starts from zero, making the first element in a list or array the zeroth element.

タスク

スワイプしてコーディングを開始

You have a student with grades in 4 subjects. Your task is to calculate the student’s average grade across all subjects.

  • The function calculateAverage takes an array of 4 integers representing the student’s grades.
  • Inside calculateAverage, add up all the grades in the array.
  • Then, divide the total by 4.0 (as a double) to get the average grade.

Example

{80, 90, 75, 95} => 85.0
{100, 100, 100, 100} => 100.0
{70, 80, 75, 76} => 75.25

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  16
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt