Search
 
SCRIPT & CODE EXAMPLE
 

CPP

subtraction of a 2d matrix in c++

Subtract or add 2d matrix

#include<iostream>
using namespace std;
int main()
{
    int matOne[3][3], matTwo[3][3], matSub[3][3], i, j;
    cout<<"Enter 9 Elements for First Matrix: ";
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            cin>>matOne[i][j];
    }
    cout<<"Enter 9 Elements for Second Matrix: ";
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            cin>>matTwo[i][j];
    }
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            matSub[i][j] = matOne[i][j] - matTwo[i][j];
    }
    cout<<"
The New Matrix (Subtraction Result) is:
";
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            cout<<matSub[i][j]<<"  ";
        cout<<endl;
    }
    cout<<endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: How do you count the occurrence of a given character in a string? c++ 
Cpp :: how to find second smallest element in an array using single loop 
Cpp :: uint16_t does not name a type 
Cpp :: c++ online 
Cpp :: full pyramid in c++ 
Cpp :: how to type a vertical stack program c++ 
Cpp :: arithmetic progression c++ 
Cpp :: gdb get return value of function 
Cpp :: adding two dates using necessary member function in c++ 
Cpp :: c++ program to convert fahrenheit to kelvin 
Cpp :: sfml thread multi argument function 
Cpp :: cout ascii art c++ 
Cpp :: move semantics in c++ 
Cpp :: why wont a function stop C++ 
Cpp :: overload operator object function call 
Cpp :: how to install open cv2 in c++ on ubuntu 
Cpp :: how to point to next array using pointer c++ 
Cpp :: contains in c++ map 
Cpp :: how to modify set C++ 
Cpp :: #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") 
Cpp :: Chef and the Wildcard Matching codechef solution in c++ 
Cpp :: c++ sort cout end 
Cpp :: determining a string is subsequence of another 
Cpp :: quiz arrary and pointers in c++ 
Cpp :: c++ start thread later 
Cpp :: ros pointcloud2 read_points c++ 
Cpp :: bash script add another user 
Cpp :: spyder enviroment 
Cpp :: c++ fps sleep while loop 
Cpp :: constructor init list 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =