answersLogoWhite

0

#include
#include
void main()
{ int a[10][10],b[10][10],c[10][10];
printf("\nEnter the Row:");
scanf("%d",&r);
printf("\nEnter the Columns:");
scanf("%d",&c);
for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];
printf("\nThe Result is:\n");
for(i=0;i{ for(j=0;jprintf("%d\t",c[i][j]);
printf("\n");
}
getch();
}
Syntactical errors may happened.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Can you give the explanation for various operations in a queue implementation using arrays?

The following are operations performed by queue in data structuresEnqueue (Add operation)Dequeue (Remove operation)Initialize


Making multiplication table in c plus plus using do while loop?

Um, not sure how to do that, but you can create a sort of "table" in C++ by using multidimensional arrays. Below is an example of how to create a two-dimensional array: int myArray[10] [10]; You can add more dimensions to the array in order to increase its storage capacity.


Flow chart for addition of two matrices?

For the resulting matrix, just add the corresponding elements from each of the matrices you add. Use coordinates, like "i" and "j", to loop through all the elements in the matrices. For example (for Java; code is similar in C):for (i = 0; i


How do you write a C program to add 2 matrices using functions?

We'll assume the matrix elements are doubles, but we can easily adapt the code to cater for any numeric data type. First we need a (primitive) function that emulates the += operator for two arrays of doubles: double* add_assign_array (double* a, double* b, size_t sz) { for (size_t i=0; i<sz; ++i) a[i] += b[i]; return a; } Note that we are wholly reliant upon the caller to ensure all arguments are valid. We could test for null pointer arguments, however there's no advantage in doing so when we cannot even guarantee that a and b actually refer to at least sz elements. For efficiency it's better if the caller handles any and all necessary runtime tests and thus keep those tests to a minimum. With this function in place we can now add two matrices, row by row: double* add_assign_matrix (double* a, double* b, size_t rows, size_t cols) { size_t i; for (size_t row=0; row<rows; ++row) { i = row * cols; add_assign_array (a[i], b[i], cols); } return a; } Example usage: // Utility functions: void print_array (double*, size_t); void print_matrix (double*, size_t, size_t); int main (void) { const size_t rows = 3; const size_t cols = 4; double a[rows][cols] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; double b[rows][cols] = {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}; printf ("Matrix a:\n"); print_matrix (a, rows, cols); printf ("Matrix b:\n"); print_matrix (b, rows, cols); printf ("Matrix a+=b:\n"); add_assign_matrix (a, b, rows, cols); print_matrix (a, rows, cols); return 0; } void print_array (double* a, size_t sz) { for (size_t i=0; i<sz; ++i) printf ("%f\t") a[i]; printf ("\n"); } void print_matrix (double* a, size_t rows, size_t cols) { for (size_t row=0; row<rows; ++row) print_array (a[row * cols], cols); } Note that the add_assign function emulates a += b rather than c = a + b. However, we can easily emulate this by copying one of the matrices and then calling add_assign upon the copy: // e.g., c = a + b; double c[rows][cols]; // uninitialised matrix memcpy (c, a, rows * cols * sizeof (double)); // c is a copy of a add_assign_matrix (c, b, rows, cols); // c += b It's far from intuitive but arrays and matrices are anything but intuitive in C programming.


How do you add and subtract 16 bit numbers using 8051 microprocessor?

The 8051 is a microcontroller, not a microprocessor. To add or subtract, use the ADD or SUBB opcodes.

Related Questions

How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


What must be true in order to add matrices?

They must have the same dimensions.


How do you add fractions in matrices?

The usual rules of addition of fractions apply.


Is there any benefit in a C plus plus program to add two matrices?

No.


A graphic artist thinks he can add the matrices below using mental math. Which statement explains why he could be correct?

adding the additive identity matrix does not change the original matrix


How do you add matrices?

You add matrices by adding their respective terms - e.g. the element in the first row and sixth column of the sum is the sum of the elements in the addends' first rows and sixth columns. Wikipedia has a nice example of matrix addition that I linked below.


Can you give the explanation for various operations in a queue implementation using arrays?

The following are operations performed by queue in data structuresEnqueue (Add operation)Dequeue (Remove operation)Initialize


Can a matrix of 4x5 be added with a matrix with dimensions of 5x3?

No. You can only add matrices of the same size.


Can you add two matrices with different dimensions?

No, you cannot add matricies of different dimention/order (i.e. different number of rows or columns)


How do you solve a matrix?

Please clarify what you want to "solve". There are several operations you can do with matrices, such as add them, multiply them, transpose them, etc.


What are different Uses of matrices in our daily lifeor what are the applications of matrices?

Matrices are used to figure who is seeded in a contest like the NCAA basketball final four. Matrices are used in any calculation that has to do with multiple variables. In business the maximum that you charge for a ticket and make the most money, I have used matrices.


How can I multiply two 2x2 matrices?

To multiply two 2x2 matrices, you need to multiply corresponding elements in each row of the first matrix with each column of the second matrix, and then add the products. The resulting matrix will also be a 2x2 matrix.