Simple C Program with Algorithm, Flowchart, Output - Computer Programming - C
Write a program for
matrix multiplication.
AIM
To
write a program for matrix multiplication.
ALGORITHM
Step‒1 :
Start
Step-2 :
Read size of the array m,n
Step-3 :
Check p is equal to n, if not go to step 12
Step-4 :
Read matrix value a[i][j]
Step-5 :
Read matrix value b[i][j]
Step-6 :
Set a loop to calculate matrix multiplication
Step-6 :
d[i][j]=0; d[i][j]=d[i][j] +a[i][k]*b[k][j]
Step-8 :
Set a loop to print matrix values
Step-9 :
Print matrix value d[i][j], after completing goto step 14
Step-10 :
If step‒3 is not equal then
Step‒11 :
Print the number of rows and columns should not be equal.
Step‒12 :
Stop
FLOWCHART

PROGRAM
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],d[10][10], i,j,p,q,m,n,k;
printf("Enter size of the A matrix :");
scanf("%d %d", &p,&q);
printf("Enter size of the B matrix");
scanf("%d %d",&m,&n);
if(p==n)
{
printf("Enter the elements of A matrix.\n “);
for(i=0;i<p;i++)
{
for(j=0;j<q;j++):
scanf("%d",&a[i][j]);
}
printf("Enter the elements of B matrix. \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
d[i][j]=0;
for(k=0;k<p;k++)
d[i][j]=d[i][j]+a[i][k]*b[k][j];
}
}
printf("Multiplication of A and B matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%5d
",d[i][j]);b
printf("\n");
}
}
printf("The no.of rows and coloums should bot be
equal.");
}
OUTPUT
Enter size of the A
matrix :33
Enter size of the B
matrix : 3 3
Enter the elements of
A matrix. 1 2 3 4 5 6 7 8 9
Enter the elements of
B matrix. 2 4 1 6 7 4 3 5 7
Multiplication of A and B matrix:
23 33 30
56 81 66
89 129 102
Computer Programming C Laboratory: Practical C Programs : Tag: C Programming : C Program with Algorithm, Flowchart, Output - Write a C program for matrix multiplication
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation