[ create a new paste ] login | about

Link: http://codepad.org/8i7MlSP4    [ raw code | output | fork ]

C++, pasted on Apr 30:
#include <iostream>
using namespace std;
#include <cstdlib>

void fn(int **arr) {

}
void fn2 (int **arr2){

}
void fn3 (int **arr3){

}
int main() {

	int r, c ,r2 , c2 , r3 , c3 , m , l;

	cout << "Enter size of row 1 : " ;
	cin >> r ;
	cout << "Enter size of column 1 : " ;
	cin >> c ;
	cout <<"Enter matrix 1 please " ;

	int **arr = new int*[r];
	for (int i = 0; i < r; i++)
		arr[i] = new int[c];

	for (int i=0 ; i<r ; i++){
		for (int j=0 ; j<c ; j++)
                    cin >> arr[i][j] ;
	}
	for (int i=0 ; i<r ; i++){
		for (int j=0 ; j<c ; j++)
			 cout << arr[i][j]<<" " ;
		cout << endl ;
	}
	cout << "Enter size of row 2 : " ;
	cin >> r2 ;
	cout << "Enter size of column2 : " ;
	cin >> c2 ;
	cout << "Enter matrix 2 please " ;
	int **arr2 = new int*[r2];
	for (int i = 0; i < r2 ; i++)
		arr2[i] = new int[c2];


	for (int i=0 ; i<r2 ; i++){
		for (int j=0 ; j<c2 ; j++)
			 cin >> arr2[i][j] ;
	}
	for (int i=0 ; i<r2 ; i++){
		for (int j=0 ; j<c2 ; j++)
			 cout << arr2[i][j] <<" " ;
		cout << endl ;
	}
	int **arr3 = new int*[r3];
	for (int i = 0; i < r2 ; i++)
		arr3[i] = new int[c];
	if (c == r2 ){

	for (int i=0 ; i<r2 ; i++){
		for (int j=0 ; j<c ; j++){
                    arr3[i][j]=0;
        for(int k=0;k<c;k++)
                arr3[i][j]=arr3[i][j]+(arr[i][k] * arr2[k][j]);
	}
	}
	cout<<"your matrix is"<<endl;
	for(int i=0;i<r3;i++){
            for(int j=0;j<r3;j++){
                cout<<arr3[i][j]<<" ";
    }
    cout<<endl;
    }
	}
    else
        cout << "Error"<< endl ;

    fn(arr);
	fn2(arr2);
	fn3(arr3);
	return 0;
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'int main()':
Line 56: warning: 'r3' is used uninitialized in this function


Create a new paste based on this one


Comments: