+ 1

How can we add the elements of an array?

28th Oct 2016, 11:17 AM
Harshit Rajput
Harshit Rajput - avatar
2 Answers
+ 2
if they're numbers then you can do int temp; for (int i=0,i <sizeof (array)/sizeof (array [0]);++i) temp+=array [i];
28th Oct 2016, 11:24 AM
Daniel Rollins
Daniel Rollins - avatar
+ 2
If you want your array can be resized adding new items at runtime, you must use dynamic arrays to can resize it. Sample: int *array = new int[10];
28th Oct 2016, 11:32 AM
Juan Luis GarcĂ­a
Juan Luis GarcĂ­a - avatar