Basic Programs

If Else based Programs

Loop Based Programs

Array Based Programs

String Programs

Function Programs

Pointers Programs

Structure & File Handling Programs

Data Structure Programs

Array based programs

Matrix Addition Program

#include<stdio.h>
#include<conio.h>
void main()
{
    int rows, cols, i=0, j=0, m1[10][10], m2[10][10], sum[10][10];
    
printf("Enter the number of rows and columns of matrix upto 10\n");     scanf("%d%d", &rows, &cols);     printf("Enter the elements of first matrix\n");          
for (i = 0; i< rows; i++)       {          for (j= 0; j < cols; j++)           {               scanf("%d", &m1[i][j]);             }       }     printf("Enter the elements of second matrix\n");          
for (i = 0; i< rows; i++)        {           for (j= 0; j < cols; j++)             {                 scanf("%d", &m2[i][j]);                 sum[i][j] = m1[i][j] + m2[i][j];             }         }       printf("Sum of entered matrices:-\n");          
 for (i = 0; i< rows; i++)         {            for (j= 0; j < cols; j++)              {                 printf("%d\t", sum[i][j]);               }             printf("\n");         } }

Output of the above program is as following.

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial