Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

sum of 2 arrays c++

#include <iostream>

int main(){
  	float sum=0;
    int array [3][5] = 
    {
        { 1, 2, 3, 4, 5, }, // row 0
        { 6, 7, 8, 9, 10, }, // row 1
        { 11, 12, 13, 14, 15 } // row 2
    };
  
  for ( i = 0; i < 3; i++ ){
  	for ( j = 0; j < 5; j++ ){
      sum+=array[i][j];
  	}
  }
  std::cout << sum << std::endl;
  
}
 
PREVIOUS NEXT
Tagged: #sum #arrays
ADD COMMENT
Topic
Name
3+2 =