# (Solved Homework): Write a C program that is able to view, add, or multiply two matrices input by the user. After inputting the two

Write a C program that is able to view, add, or multiply two matrices input by the user. After inputting the two matrices, the user should be presented with a menu of possible operations ◦ View the matrices ◦ Add the matrices ◦ Multiply the matrices ◦ Quit the program The user should be able to make a choice, see the outcome of the operation, and then make another choice from the menu. The program should continue to operate in this manner until the user selects the quit action, at which point the program should exit. 1. Collect user input for two matrices ◦ The size of each matrix in rows and columns ◦ The data stored in the matrices The user should be able to input up to a 5×5 matrix. Your program should be able to support any size up to a 5×5 (e.g. 2×3, 1×2, 4×4, 5×3, etc). The matrices should hold double type floating point numbers and be stored in a single or multidimensional array. 2. Display a menu of available options that includes, at least, the following ◦ View the matrices ◦ Add the matrices ◦ Multiply the matrices ◦ Quit the program The program should loop indefinitely until the user selects the option to quit. Each time an operation is selected, your program should perform the selected operation, display the results, and then present the user with the menu again. 3. The results of the performed operation should only be displayed and not stored, meaning they should not affect the values of the matrices input by the user. Thus performing the same operation repeatedly will return the same results. 4. Before performing an operation, you must ensure that the operation is valid. If the user has input matrices which are not compatible with the selected operation, print an error message indicating the problem and then present them with the menu again. Do not simply quit the program.

The program is as follows:

#include<stdio.h>

void main(){

int row1, col1,
int row2, col2;
int sum;
int i, j, k,l;
int first[5][5], second[5][5];
int choice;

do {
printf(“Enter the number of rows and columns of first matrixn”);
scanf(“%d%d”, &row1, &col1);
if (row1 > 5 || col1 > 5)
printf(“The maximum value for row or column is 5n”);

} while (row1 > 5 && col1 > 5)

printf(“Enter the elements of first matrixn”);

for (i = 0; i < row1; i++)
for (j = 0; j < col1; j++)
scanf(“%d”, &first[i][j]);

do {
printf(“Enter the number of rows and columns of second matrixn”);
scanf(“%d%d”, &row2, &col2);
if (row2 > 5 || col2 > 5)
printf(“The maximum value for row or column is 5n”);

} while (row2 > 5 && col2 > 5)

printf(“Enter the elements of second matrixn”);

for (i = 0; i < row2; i++)
for (j = 0; j < col2; j++)
scanf(“%d”, &second[i][j]);

do {
printf(“1.View the matricesn”);
printf(“3.Multiply the matricesn”);
printf(“4.Quitn”);

switch (choice) {
case 1:
printf (“First Matrix:nn”);
for (i = 0; i < row1; i++){
for (j = 0; j < col1; j++)
printf(“%d %c”, first[i][j], ‘ ‘);
printf(“n”);
}
printf (“Second Matrix:nn”);
for (i = 0; i < row2; i++){
for (j = 0; j < col2; j++)
printf(“%d %c”, second[i][j], ‘ ‘);
printf(“n”);
}
case 2:
if ((row1 == row2) && (col1 == col2)){
printf (“Sum of Matrices:nn”);
for (i = 0; i < row1; i++){
for (j = 0; j < col1; j++)
printf(“%d %c”, first[i][j]+second[i][j], ‘ ‘);
printf(“n”);
}
}
else {
printf(“Rows and columns of matrices are not compatible for additionn”);
}

case 3:
if (col1 == row2){
printf (“Multiplication of Matrices:nn”);
for (i = 0; i < row1; i++){
for (j = 0; j < col2; j++){
sum = 0;
for (k=0; k<col1; k++)
sum = sum + first[i][k] * second[k][j];

printf(“%d %c”, sum, ‘ ‘);
}
printf(“n”);
}
}
else {
printf(“Rows and columns of matrices are not compatible for multiplicationn”);
}

}

} while (choice ! = 4)

}

Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Follow these simple steps to get your paper done

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.