addition of array elementsdefine rows 3define


Addition of array elements:

#define rows 3

#define cols 3

void main()

{

                int i=0,j=0,sum=0;

                int arr[rows][cols];

                for (i=0; i<=rows-1; i++)

                                for(j=0;j<=cols-1;j++)

                                {

                                                printf("Enter elements (%d,%d)\n",(i+1),(j+1));

 

                                                scanf("%d",&arr[i][j]);

                                }

                for (i=0; i<=rows-1; i++)

                {

                                printf("\t");       

                                for(j=0;j<3;j++)

                                                {

                                                printf("%3d  ",arr[i][j]);

                                                }

                                                printf("\n");

                }

                printf("\n Sum of matrix\n");

                for(i=0;i<=rows-1;i++)

                                for(j=0;j<=cols-1;j++)

                                {

 

                                                sum=sum+arr[i][j];

                                }

printf("\tsum=%d\n",sum);                       

}

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: addition of array elementsdefine rows 3define
Reference No:- TGS0162088

Expected delivery within 24 Hours