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
  • х у V 1.0 7.6 1.0 1.0 2.0 8.7 11 2.0 2.0 3.0 7.3 3.0 3.0...

    х у V 1.0 7.6 1.0 1.0 2.0 8.7 11 2.0 2.0 3.0 7.3 3.0 3.0 4.0 5.8 11 10- 9- 8 7-1 6 5- 4+ 3+ 2 4.0 4.0 11 10 9+ 8+ 71 6+ 5+ 4+ 3+ 2+ 1. X 5.0 8.2 5.0 5.0 6.0 4.9 6.0 6.0 X 7.0 4.5 7.0 7.0 8.0 7.2. 8.0 8.0 0 1 2 3 4 5 6 7 8 9 10 11 7 8 9 10 11 9.0 5.9 9.0 9.0...

  • Below are four bivariate data sets and the scatter plot for each. (Note that each scatter...

    Below are four bivariate data sets and the scatter plot for each. (Note that each scatter plot is displayed on the same scale.) Each data set is made up of sample values drawn from a population. x y 1.0 7.9 2.0 5.1 3.0 10.1 4.0 6.4 х 11 10+ 9+ 8+ 7+ 6+ 5- X X 1.0 7.3 117 10+ 2.0 9.0 9+ 3.0 7.3 8+ 7 4.0 5.6 6+ 5.0 7.9 5 4 6.0 5.3 2 7.0 4.8 5.0...

  • For this lab, you will work with two-dimensional lists in Python. Do the following: Write a...

    For this lab, you will work with two-dimensional lists in Python. Do the following: Write a function that returns the sum of all the elements in a specified column in a matrix using the following header: def sumColumn(matrix, columnIndex) Write a function display() that displays the elements in a matrix row by row, where the values in each row are displayed on a separate line. Use a single space to separate different values. Sample output from this function when it...

  • Below are four bivariate data sets and the scatter plot for each. (Note that each scatter...

    Below are four bivariate data sets and the scatter plot for each. (Note that each scatter plot is displayed on the same scale.) Each data set is made up of sample values drawn from a population. y 1.0 7.4 2.0 9.0 3.0 7.0 11 10- 11 102 9 8+ 7+ 8+ 71 61 5 5 41 4.0 5.4 5.0 7.5 6.05.2 7.0 4.5 8.0 7.1 9.0 5.5 10.0 3.9 V 1.0 8.0 2.0 6.9 3.07.3 4.0 6.1 5.0 7.4 6.0...

  • Boxes Task: Evaluate whether you can load various sizes of jars into boxes. For each test,...

    Boxes Task: Evaluate whether you can load various sizes of jars into boxes. For each test, you will input the length, width, and height of a box as well as the diameter and height of a cylindrical jar. The algorithm will determine whether each jar will fit in its corresponding box. The jar can sit upright in the box, or it can lie on its side with its top parallel to one of the sides of the box.   Assume that...

  • A variety of spectra for an organic compound with molecular formula C10H16O are presented below. The experimental accurate mass using (+) APCI source is 153.1280 u. The 1H, 13C, COSY, HSQC and HMBC NM...

    A variety of spectra for an organic compound with molecular formula C10H16O are presented below. The experimental accurate mass using (+) APCI source is 153.1280 u. The 1H, 13C, COSY, HSQC and HMBC NMR spectra are given in the following slides. Propose a structure for this unknown and answer or address the following questions or requirements: d. If there are still any questionable assignments, propose additional NMR experiments which would solve those questions and briefly explain specifically what correlations you...

  • A variety of spectra for an organic compound with molecular formula C10H16O are presented below. The experimental accurate mass using (+) APCI source is 153.1280 u. The 1H, 13C, COSY, HSQC and HMBC NM...

    A variety of spectra for an organic compound with molecular formula C10H16O are presented below. The experimental accurate mass using (+) APCI source is 153.1280 u. The 1H, 13C, COSY, HSQC and HMBC NMR spectra are given in the following slides. Propose a structure for this unknown and answer or address the following questions or requirements: a. Using the most abundant isotopes of C, H and O, what are the errors in ppm and milli-Daltons for the experimental accurate mass?...

  • Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array...

    Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array is randomly initialized (using Math.random()). Write a method to find the maximum value in this two dimensional array; Write a method to find the average value in the array; Write a method to count how many elements are smaller than average; Write a method to copy contents in a two-dimensional array to a one-dimensional array. The method will return this one-dimensional array. Method is...

  • ETM-3030 DIVING SCORES EXCEL 10 POINTS In this assignment you will use excel to process the score...

    ETM-3030 DIVING SCORES EXCEL 10 POINTS In this assignment you will use excel to process the scores of a diving competition. In the next assignment you will solve the same problem using C#. The diving works as follows: A set of judges score each dive from o0 to 10 in stes of 0.5. The total score for a dive is obtained by discarding the lowest and highest of the judges' scores, adding the remaining scores, and multiplying the result by...

  • Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic...

    Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic singly linked list that can hold any data type. The interface has been specified and provided to you in a header file called mylist.h. So your job is to write mylist.c that implements each function whose prototype is included in mylist.h. Specifically, you are asked to write the following functions: struct Node *addFront(struct List *list, void *data) void traverseList(struct List *list, void (*f)(void *))...

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