Write a C program to perform the following operation on matrices D = A + (B * C), where A, B and C are matrices of (3 X 3) size and D is the resultant matrix – IGNOU MCA Assignment 2018 – 19

By | July 24, 2018

MASTER OF COMPUTER APPLICATIONS

Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2018-19
Maximum Marks : 100

Write a C program to perform the following operation on matrices D = A + (B * C), where A, B and C are matrices of (3 X 3) size and D is the resultant matrix – IGNOU MCA Assignment 2018 – 19

Program:

#include<stdio.h>
void main()
{
int A[3][3],B[3][3],C[3][3],D[3][3],I,J,K;
clrscr();
printf(“ENTER 3X3 MATRIX A VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&A[I][J]);
}
}
printf(“ENTER 3X3 MATRIX B VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&B[I][J]);
}
}
printf(“ENTER 3X3 MATRIX C VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&C[I][J]);
}
}
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
D[I][J]=0;
for(K=0;K<3;K++)
{
D[I][J]=D[I][J]+A[I][K]*B[K][J];
}
D[I][J]=D[I][J]+C[I][K];
}
}
printf(“RESULT 3X3 MATRIX D VALUES ARE :\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
printf(“%d\t”,D[I][J]);
}
printf(“\n”);
}
getch();
}

Code:

[codesyntax lang=”c”]

#include<stdio.h>
void main()
{
int A[3][3],B[3][3],C[3][3],D[3][3],I,J,K;
clrscr();
printf(“ENTER 3X3 MATRIX A VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&A[I][J]);
}
}
printf(“ENTER 3X3 MATRIX B VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&B[I][J]);
}
}
printf(“ENTER 3X3 MATRIX C VALUES\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
scanf(“%d”,&C[I][J]);
}
}
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
D[I][J]=0;
for(K=0;K<3;K++)
{
D[I][J]=D[I][J]+A[I][K]*B[K][J];
}
D[I][J]=D[I][J]+C[I][K];
}
}
printf(“RESULT 3X3 MATRIX D VALUES ARE :\n”);
for(I=0;I<3;I++)
{
for(J=0;J<3;J++)
{
printf(“%d\t”,D[I][J]);
}
printf(“\n”);
}
getch();
}

[/codesyntax]

Screen Shots:

C_program_Matrix_Multi_Add

C_program_Matrix_Multi_Add_Output

II) Write an interactive C program to calculate the string length of a given string, using pointers.

Solved program can be found on this link http://cssimplified.com/c-programming-data-structure/write-a-program-to-generate-the-pattern-10m-jun2007