Start New Discussion within our Software Development Community

Problem Statement:

Write a program that adds two matrices A and B of order 2X4 and store the result in third matrix C and C is stored in a file “result.txt. The program should take the values from the user in the matrices through a function input. The addition of the Matrices should be calculated through a function add. The resultant matrix should be written in the file through a function save. Also display the result in a good looking format on the screen in a function show() .
Design and Implementation:
You are required to make three functions named as:
input()
This function will read values in the two Matrices.
add()
This function will take the two Matrices as arguments and add them and the result will be stored in a third matrix.
save()
This function will take the resultant matrix as argument and saves it to a file.
show()
This function will display the resultant matrix on the screen.


Hint 1: A two dimensional array is known as matrix in mathematics.
Hint 2: show() and save() should be called from add() respectively.

Sample output:

The following prototypes for the respective functions can be used to implement the above mentioned problem:

void input();

void Add( int arr1[][] , int arr2[][] );

void show( int array3[][] );

void save( int arr3[][] );

Your output can be similar with the following:

Enter values for first A:
2
3
1
1
5
3
2
4
Enter values for B:
4
2
3
1
8
9
1
4
Matrix C is:

6 5 4 2

13 12 3 8[/i] :eek:

I must be near-blind or something because I don't see any of your code where you attempted to solve that problem youself :evil: Don't let that overwhelm you. Take the problem one step at a time and you will be able to solve it.

This article has been dead for over six months. Start a new discussion instead.