void main()
{
int a[5][5],i,j,row[5];
clrscr();
//Read Matrix
printf("\n-----Enter 5X5 matrix below:-------\n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
scanf("%d",&a[i][j]);
}
}
//Display Matrix
printf("\n\n----- The matrix you entered is:-------\n");
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
//Perform column-wise Addition
printf("\nPerforming Calculations.........\n");
for(j=0;j<5;j++)
{ row[j]=0;
for(i=0;i<5;i++)
{
row[j]=row[j]+a[i][j];
}
}
//Display Result of column-wise calculation
printf("------The result of column-wise addition is:----\n");
for(i=0;i<5;i++)
{
printf("Column %d ",i+1);
printf("\t %d\n",row[i]);
}
getch();
}
0 comments: