Solution:
#include<stdio.h>
int main(){
/* 2D array declaration*/
int disp[2][3],sum=0;
/*Counter variables for the loop*/
int i, j;
for(i=0; i<2; i++) {
for(j=0;j<3;j++) {
printf("Enter value for disp[%d][%d]:", i, j);
scanf("%d", &disp[i][j]);
}
}
//Displaying sum of all even array elements
printf("Two Dimensional array elements:\n");
for(i=0; i<2; i++) {
for(j=0;j<3;j++) {
sum=sum+disp[i][j];
}
}
}
printf("sum=%d=", sum);
return 0;
}
0 Comments