C Program to add two Matrices

In this tutorial you will learn about the C Program to add two Matrices and its application with practical example.

C Program to Add Two Matrices

In this tutorial, we will learn to create a C program that will add Two Matrices using C programming.

Table Of Contents

Prerequisites

Before starting with the tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C programming.

Algorithm:-

Program to add Two Matrices:-

In today’s tutorial, we will add two matrices. First, we will take the size of the matrix from the user, and then we will take the input elements of the two matrices. Now we will add the two elements of the matrices. At last, we will print the result matrix after adding.

Program:-

 

Output:-

In the above program, we have first initialized the required variable.

  • a[10][10]= it will hold the integer value.
  • rw = it will hold the integer value for the loop.
  • cl = it will hold the integer value for the loop.
  • i= it will hold the input integer value for rows.
  • j= it will hold the input integer value for columns.

Taking the size and the elements of the two matrices from the user.

Adding the matrices one from another.

Printing the matrix after adding.

In this tutorial we have learn about the C Program to add two Matrices and its application with practical example. I hope you will like this tutorial.