Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Safe Array Access | Working with Array Elements
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C++ Arrays

bookChallenge: Safe Array Access

Tâche

Swipe to start coding

Write a function sumArray that takes a constant integer array and its size as parameters and returns the sum of all elements in the array.

  • Access only valid indices in the array (from 0 to size - 1);
  • Do not use any global variables or additional libraries;
  • Declare and initialize the array in main, then pass it with its size to sumArray;
  • Return the total sum from the function.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Safe Array Access

Glissez pour afficher le menu

Tâche

Swipe to start coding

Write a function sumArray that takes a constant integer array and its size as parameters and returns the sum of all elements in the array.

  • Access only valid indices in the array (from 0 to size - 1);
  • Do not use any global variables or additional libraries;
  • Declare and initialize the array in main, then pass it with its size to sumArray;
  • Return the total sum from the function.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
single

single

some-alt