+ 2

Write a c++ program that uses a " for loop" to calculate the sum of six elements of an "array."

C++

2nd Aug 2017, 9:11 PM
Ezeukwu Princewill Chigozie
Ezeukwu Princewill Chigozie - avatar
3 Answers
2nd Aug 2017, 10:30 PM
ChessMaster
ChessMaster - avatar
+ 3
int sum = 0; int arr[6] = {1, 2, 3, 4, 5, 6}; for(size_t i = 0; i < 6; i++) sum += arr[i];
2nd Aug 2017, 10:03 PM
ChessMaster
ChessMaster - avatar
+ 1
@CheeseMaster it didn't run
2nd Aug 2017, 10:27 PM
Ezeukwu Princewill Chigozie
Ezeukwu Princewill Chigozie - avatar