this is a program to enter the elements of a square matrix and find the smallest element from each row and subtract the minimum value from all the values in the respective rows.........take the input as the following values
999 54 48 92 24
54 999 32 61 35
48 32 999 45 23
92 61 45 999 67
24 34 23 67 999
so the output should be.......
975 30 24 68 0
22 967 0 29 3
25 9 976 22 0
47 16 0 954 22
1 11 0 44 976
but i'm getting output as.......
975 30 24 68 0
30 975 8 37 11
25 9 976 22 0
69 38 22 976 44
1 11 0 44 976
pls temme wat is da error in ma program........
#include<stdio.h>
#include<conio.h>
main()
{
int n,M[10][10],min=3267;
printf("\nEnter the order of square matrix:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
printf("\nEnter the elements of the row %d:",i);
for(int j=1;j<=n;j++)
{
scanf("%d",&M[i][j]);
}
}
for(i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
printf("\t %d",M[i][j]);
}
printf("\n");
}
printf("\nNow subtract each element from every row from their respective minimum value\n");
getch();
for(i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(M[i][j]<min)
min=M[i][j];
}
for( j=1;j<=n;j++)
M[i][j]=M[i][j]-min;
}
for(i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
printf("\t %d",M[i][j]);
}
printf("\n");
}
}