C program to find the sum of 2 matrices ( Program 24)

/*
Made by Anmol main
Student :B.tech CSE 
Punjabi university Patiala
Program No. : 24
*/
#include <stdio.h>
#define m 5
#define n 5
int main()
{
    int ijk;
    int arowsacolumsbrowsbcolumssum = 0;
    int a[m][n];
    int b[m][n];
    int p[m][n];
    //getting input of two matrices from the user
    printf("\nEnter the number of rows : ");
    scanf("%d"&arows);
    printf("Enter the number of colums : ");
    scanf("%d"&acolums);

    for (i = 0i < arowsi++)
    {
        for (j = 0j < acolumsj++)
        {
            scanf("%d"&a[i][j]);
        }
    }
    printf("\nEnter the number of rows : ");
    scanf("%d"&brows);
    printf("Enter the number of colums : ");
    scanf("%d"&bcolums);
    if (arows == bcolums)
    {
        for (i = 0i < arowsi++)
        {
            for (j = 0j < acolumsj++)
            {
                scanf("%d"&b[i][j]);
            }
        }
        //input completed
        //printing two matrices
        printf("\n\nYou entered matrix A :\n");
        for (i = 0i < arowsi++)
        {
            printf("\n");
            for (j = 0j < acolumsj++)
            {
                printf("%d "a[i][j]);
            }
        }
        printf("\n\nYou entered matrix B :\n");
        for (i = 0i < browsi++)
        {
            printf("\n");
            for (j = 0j < bcolumsj++)
            {
                printf("%d "b[i][j]);
            }
        }
        //printing of two matrices completed
        //printing the sum of two matrtices
        for (i = 0i < arowsi++)
        {
            printf("\n");
            for (j = 0j < bcolumsj++)
            {
                p[i][j= a[i][j+ b[i][j];
            }
        }
        for (i = 0i < arowsi++)
        {
            printf("\n");
            for (j = 0j < bcolumsj++)
            {
                printf("%d "p[i][j]);
            }
        }
    }
}

Comments

Popular posts from this blog

Glowing-Log-in-window-in-Pure-html-css #30

Program to swap 2 numbers by using 3 numbers, taking input from user in C language. #1

C program to print lengh of an array (program 20)