Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen.

Posted on October 26, 2021 By myustaadg.com
Spread the love
Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen.
Note: The addition of matrices A and B is obtained by adding the elements of A to the corresponding elements of B. To add/subtract two matrices, the number of rows and columns of two matrices must be equal. For example:
A = ad be cf B = gj hk il
A + B = (a + g)(d + j) (b + h)(e + k) (c + i)(f + l)
Addition of matrices.

So let’s Write Code:

Introduction to C++ Programming | Download and Install Dev C++ Compiler

Code:

Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen.

#include<iostream>
using namespace std;
main()
{
int A[3][3] = {{2,3,8},{5,8,3},{2,6,3}};
int B[3][3] = {{2,3,1},{6,1,2},{6,2,1}};
int C[3][3];
void addition(int[3][3], int[3][3], int [3][3]);
void print(char [15], int [3][3]);
addition(A, B, C);
print("Matrix A: ", A);
print("Matrix B: ", B);
print("addition of A & B ", C);
}
// definition of addition() function
void addition(int X[3][3], int Y[3][3], int Z[3][3])
{
int r, c;
for(r = 0; r<=2; r++)
for(c = 0; c<=2; c++)
Z[r][c] = X[r][c]+Y[r][c];
}
// definition of print() function
void print( char str[], int R[3][3])
{
int r, c;
cout<<endl<<str<<endl;
for(r = 0; r<=2; r++)
{
for(c = 0; c<=2; c++)
cout<<R[r][c]<<"\t";
cout<<endl;
}
}

Hope You will learn Something. Happy Coding.

Visit my YouTube Channel as Well😇 https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

Click on the below Links for more Programming Exercises:

Conditional Structure Exercises: 👉https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

Array Exercises: 👉https://myustaadg.com/category/programming-exercises/arrays-exercises/

Arrays Exercises, Programming Exercises Tags:array declaration in c++, Array Exercises, Array exercises in C++, Arrays, Arrays - Introduction to Programming, arrays arrays in c++, arrays codes, Arrays exercises, Arrays in C++ Programming with examples, Arrays in Programming, Arrays with example, C++ and C two dimensional arrays tutorial, C++ Arrays, c++ arrays declaration and initialization, C++ Arrays with examples, C++ Program for Two Dimensional (2D) Array, Creating and Using Arrays, Data structures and algorithms in c++, How can I create a two dimensional array in c++, how do you initialize an array in c++, how to display elements of arrays, How to initialize all members of an array to the same value?, Multi-dimensional Tutorials & Notes | Data Structures, Multidimensional Arrays in C / C++, Practical C++ Programming, Simple arrays code, Two dimensional (2D) arrays in C programming with example, Two Dimensional Array in C++, Two Dimensional Arrays in C++ with Examples, Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C., Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen.

Post navigation

Previous Post: Write a program that inputs data into a string and searches the ‘vowel’ characters from the string and displays on the screen.
Next Post: Write a program that searches a value in an array using the Sequential Search method and replaces it with another one.

More Related Articles

Write a program using two arrays and enter values in 1st array. The program should copy the values of the 1st array to 2nd array. Arrays Exercises
Write a program that inputs values into two linear arrays. It adds the two arrays and stores the sum in the third array. Arrays Exercises
Write a program that inputs temperatures for seven days of the week into a one-dimensional array “temp”. Arrays Exercises
Write a program that inputs values into int type array. It reads the value from array and draws a bar chart by printing asterisks. Arrays Exercises
Write a program that asks the user for the number of hours worked and the cost per hour. Then show payment on the screen that corresponds to you | Python Programming Programming Exercises
Write a program that inputs data into a string and searches the ‘vowel’ characters from the string and displays on the screen. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme