answersLogoWhite

0


Best Answer

/*

@Autor: MD moniruzzaman

http://www.youngprogrammer.com

*/

#include<stdio.h>

#define maxn 5

int matrix[maxn][maxn] = { {1,2,3,3,4},{2,3,4,1,2},{ 4,5,6,7,8},{3,4,5,6,9},{4,3,2,1,0}};

/*

Given matrix is:

1 2 3 3 4

2 3 4 1 2

4 5 6 7 9

3 4 5 6 9

4 3 2 1 0

*/

int main() {

int sum = 0, i, j;

for(i = 0; i<5; i++) {

for(j = 0; j<5; j++) {

sum+= matrix[i][j];

}

}

printf("%d\n",sum);

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find sum of all elements of a matrix?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Educational Theory

How do you discuss the elements of design in a research paper?

Choose a particular work of art and look at it with the elements of design in mind. Write down all impressions as you view the art, are the lines rigid or flowing, how is texture used, etc. Then simply assemble all of your impressions into sentences and paragraphs.


Which educational program stated that all students would enter school ready to learn?

goals 2000


What is graduate profile definition?

Graduate outcomes that all students should achieve or corresponds to the ideal of what we hope our graduates will be expected to do after completion of the program.


How do you prepare for fashion design school?

I'm sure that everyone will have their opinions on how to answer this question but I would say reading as many fashion magazines as possible and just practicing your craft. Also, do research into schools with the best fashion design programs. Look up your favorite fashion designers and find out where they graduated. My favorite designers that I follow are Juicy Couture, Monique Lhuillier and Nick Verreos and all graduated from the fashion design program at FIDM. The school also has killer industry connections and their classes are cutting edge. It may be worth looking into their program :)


Is it possible to change your learning style?

Learning Styles Are About PreferencesIn virtually all studies and research into the differences in the way that one person learns from the way that another person learns it is found that people share almost all elements in common. What makes each person's style of learning unique is that people are found to have preferences for certain elements or options involved in the process of learning over other elements or options.The question might be asked, Is it possible to change your preferences for different elements or options in the learning process? In answer to this, it would probably be best to say that it is not clearly understood what makes these preferences, or how changeable they are, but as preferences they are only a kind of influence, even if a strong influence, and do not force a person, under most circumstances, to only learn well with one learning style.

Related questions

Write a C program using dynamic memory allocation to find the sum of elements of a matrix?

Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.


Is the scalar matrix is always a identity matrix?

No. A scalar matrix is a diagonal matrix whose main diagonal elements are the same. Only if the diagonal elements are all 1 is it an identity matrix.


What is scalene matrix?

A square matrix is said to be scalene Matrix if it has all principal diagonal elements equal and remaining all


What is the definition of zero matrix?

Zero Matrix When all elements of a matrix are zero than the matrix is called zero matrix. Example: A=|0 0 0|


A c program to square matrix?

A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.


C program to sort all elements of a 4x4 matrix?

This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


What information can be found on the Matrix Wiki website?

The Matrix Wiki website has all information related to the popular Matrix trilogy movie series on it. It has articles about characters, plot elements and lots of other interesting facts.


What's the determinant of a matrix?

A determinant is defined for square matrices only.To find the determinant of the matrix you need to:find all n-tuples of elements of the matrix such that each row and each column of the matrix is represented.calculate the product of the elements.calculate the sign for that term. To see how this is done, see below.calculate the sum of the signed products: that is the determinant.To calculate the sign for the product of the n-tuple, arrange the elements in row order. Swap the elements, two at a time, to get them in column order. If the number of swaps required is even then the product is assigned a positive sign, and if odd then a negative sign.


What is the determinant of a matrix?

A determinant is defined for square matrices only.To find the determinant of the matrix you need to:find all n-tuples of elements of the matrix such that each row and each column of the matrix is represented.calculate the product of the elements.calculate the sign for that term. To see how this is done, see below.calculate the sum of the signed products: that is the determinant.To calculate the sign for the product of the n-tuple, arrange the elements in row order. Swap the elements, two at a time, to get them in column order. If the number of swaps required is even then the product is assigned a positive sign, and if odd then a negative sign.


How to find the inverse of a symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the inverse of a square matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.


How to find the Inverse of a square symmetric matrix?

You can factorize the matrix using LU or LDLT factorization algorithm. inverse of a diagonal matrix (D) is really simple. To find the inverse of L, which is a lower triangular matrix, you can find the answer in this link.www.mcs.csueastbay.edu/~malek/TeX/Triangle.pdfSince (A T )-1 = (A-1 )T for all matrix, you'll just have to find inverse of L and D.