Back To C++ Double Dimensional Arrays Index
//program to initialize 3x3 matrix and find sum of upper and lower triangle of the matrix (example of double dimensional arrays) #include
#include
void main() { int a[3][3]={ 1,2,3, 4,5,6, 7,8,9 }; int i,j; int sumu=0,suml=0; for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(j>=i) { sumu=sumu+a[i][j]; } } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(j<=i) { suml=suml+a[i][j]; } } } cout<<"\nsum of upper triangle "<