C Program to Subtract Two Matrices

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

C Program to Subtract Two Matrices

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

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 Subtract Two Matrices:-

In today’s tutorial, we will subtract 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 subtract the two elements of the matrices. At last, we will print the result matrix after subtracting.

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.

Subtracting the matrices one from another.

Printing the matrix after subtracting.

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