Q:

C Program to perform scalar matrix multiplication

0

C Program to perform scalar matrix multiplication

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>

#define SIZE 3 

int main()
{
    int A[SIZE][SIZE]; 
    int num, row, col;

   
    printf("Enter elements in matrix of size %dx%d: \n", SIZE, SIZE);
    for(row=0; row<SIZE; row++)
    {
        for(col=0; col<SIZE; col++)
        {
            scanf("%d", &A[row][col]);
        }
    }

   
    printf("Enter any number to multiply with matrix A: ");
    scanf("%d", &num);

   
    for(row=0; row<SIZE; row++)
    {
        for(col=0; col<SIZE; col++)
        {
            
            A[row][col] = num * A[row][col];
        }
    }

    
    printf("\nResultant matrix c.A = \n");
    for(row=0; row<SIZE; row++)
    {
        for(col=0; col<SIZE; col++)
        {
            printf("%d ", A[row][col]);
        }
        printf("\n");
    }
   return 0;}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now