Question

C Language Question

Write a program to calculate the row averages of a 4x4 matrix. In main program get the elements of a 4x4 matrix and display the matrix, then call the function “average” to calculate the row averages. Function “average” will find the average of rows of a 4x4 matrix and store the results into a 1-dimensional array and return it as parameter. Main program should display the row averages which are greater than 5.0 returned by the function “average”. 

Use c language 

 

Enter 4x4 matrix elements: 5 3 8 4 7 9 6 9 2 7 6 5 7 1 3 5

 

5.0  3.0  8.0  4.0

7.0  9.0  6.0  9.0

2.0  7.0  6.0  5.0

7.0  1.0  3.0  5.0

 

Row averages greater than 5.0:

Average of row 1 = 7.8



2 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

#include <stdio.h>

void main ()

{

    

    static float array[10][10] , sum = 0;

    int i, j, m, n;

    

    printf("Enter the order of the matrix\n");

    scanf("%d %d", &m, &n);

    

    printf("Enter the co-efficients of the matrix\n");

    for (i = 0; i < m; ++i)

        {

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

                {

                    scanf("%f", &array[i][j]);

                }

        }

    

    for (i = 0; i < m; ++i) 

        {

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

                {

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

                }

            if( sum > 5.0)

                printf("Sum of the %d row is = %f\n", i, sum);

            sum = 0;

            

        }

}


answered by: codegates
Add a comment
Know the answer?
Add Answer to:
C Language Question
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT