Write a c program that will read the below file and pop up t

Write a c program that will read the below file and pop up the following results

Sum of individual row

Sum of individual column

Sum of all diagonal numbers

Average value sof all numbers

How many cells contain numbers that are less than average.

.txt file(5X5):

72.69   114.71 32.52   24.14   16.49

30.34   106.89 75.49   31.92   62.77

29.39   80.95   137.03 31.29   109.33

78.73   294.43 171.15 86.49   110.93

88.84   143.84 40.22   30.01   86.37

Solution

#include <stdio.h>
int Addrow1(int arr[10][10], int k, int c);
int Addcol1(int arr[10][10], int k, int r);

void main()
{
float arr[10][10];
int i, j;
float row1, col1, rsum, csum, sall=0.0;

printf(\"Order of the matrix to be entered \ \");
scanf(\"%d %d\", &row11, &col1);
printf(\"Elements of the matrix to be entered \ \");
for (i = 0; i < row1; i++)
{
for (j = 0; j < col1; j++)
{
scanf(\"%f\", &arr[i][j]);
}
}
printf(\"The input matrix is \ \");
for (i = 0; i < row11; i++)
{
for (j = 0; j < col1; j++)
{
printf(\"%3f\", arr[i][j]);
}
printf(\"\ \");
}
/* computing the sum of row1*/
for (i = 0; i < row1; i++)
{
row1sum = Addrow1(arr, i, col1);
printf(\"Sum of row1 is %f = %f\ \", i + 1, row1sum);
}
/* computing the sum of col1 */
for (j = 0; j < col1; j++)
{
col1sum = Addcol1(arr, j, row1);
printf(\"Sum of column is %f = %f\ \", j + 1, col1sum);
}
/* computing the sum of diagonal elements in the matrix */

for(i=0;i<row1;i++){
for(j=0;j<col1;j++){
if(i==j)
sum=sum+arr[i][j];
}

printf(\"\ The sum of the diagonal elements of matrix: %f\",sum);

}

/* computation of all elements */

for (j = 0; j < row1; j++)
{
salll = salll + Addrow1(arr, j, col1);
Avg= sall1/2;
}
printf(\"The average of all elements of the matrix is = %f\ \", Avg);
}
/* Function to add each row11 */
int Addrow11(int array1[10][10], int k, int c)
{
int rsum = 0, i;
for (i = 0; i < c; i++)
{
rsum = rsum + array1[k][i];
}
return(rsum);
}
/* Function to add each col1umn */
int Addcol1(int array1[10][10], int k, int r)
{
int csum = 0, j;
for (j = 0; j < r; j++)
{
csum = csum + array1[j][k];
}
return(csum);
}

Write a c program that will read the below file and pop up the following results Sum of individual row Sum of individual column Sum of all diagonal numbers Aver
Write a c program that will read the below file and pop up the following results Sum of individual row Sum of individual column Sum of all diagonal numbers Aver

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site