C Program to Print sum of each column individually in 2D Array.

Print sum of each column individually in 2D Array.

      Matrix [5][6]

 #include<stdio.h>
#include<conio.h>
void main( )
 {
   int arr[5][6], i , j , s=0;
   clrscr( );
 for( i=0;  i<5;  i=i+1 )
   {
     for( j=0;  j<6;  j=j+1 )
     {
      printf("Enter data ");
     scanf("%d",& arr[i][j]);
         }
     printf("\n");
   }
for( j=0;  j<6;  j=j+1 )
 {
   s=0;
 for( i=0;  i<5;  i=i+1 )
 {
   s=s+arr[i][j];
 }
printf("sum=%d\n",s);
}
getch( );
}

Post a Comment

0 Comments