start
step1:
step2:
step3:
step4:
step5:
step6:
step7:
step8:
step9:
step10:
stop
// Multiplication of Two Matrices
#include <stdio.h>
// Function to perform matrix multiplication
void multiplyMatrices(int A[10][10], int B[10][10], int result[10][10], int rowA, int colA, int rowB, int colB) {
int i,j,k;
for (i = 0; i < rowA; i++) {
for (j = 0; j < colB; j++) {
result[i][j] = 0; // Initializing the result matrix with 0
for (k = 0; k < colA; k++) {
result[i][j] += A[i][k] * B[k][j];
}
}
}
}
// Function to input matrix elements
void inputMatrix(int matrix[10][10], int rows, int cols) {
int i,j;
printf("Enter elements of the matrix (%dx%d):\n", rows, cols);
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
scanf("%d", &matrix[i][j]);
}
}
}
// Function to display a matrix
void displayMatrix(int matrix[10][10], int rows, int cols) {
int i,j;
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
printf("%d ", matrix[i][j]);
}
printf("\n");
}
}
int main() {
int A[10][10], B[10][10], result[10][10];
int rowA, colA, rowB, colB;
// Input matrix dimensions
printf("Enter the number of rows and columns for Matrix A: ");
scanf("%d %d", &rowA, &colA);
printf("Enter the number of rows and columns for Matrix B: ");
scanf("%d %d", &rowB, &colB);
// Check if multiplication is possible (columns of A must be equal to rows of B)
if (colA != rowB) {
printf("Matrix multiplication is not possible. The number of columns of A must be equal to the number of rows of B.\n");
return 1; // Exit the program if multiplication is not possible
}
// Input matrices A and B
printf("Input matrix A:\n");
inputMatrix(A, rowA, colA);
printf("Input matrix B:\n");
inputMatrix(B, rowB, colB);
// Perform matrix multiplication
multiplyMatrices(A, B, result, rowA, colA, rowB, colB);
// Display the result
printf("\nMatrix A:\n");
displayMatrix(A, rowA, colA);
printf("\nMatrix B:\n");
displayMatrix(B, rowB, colB);
printf("\nResultant Matrix (A * B):\n");
displayMatrix(result, rowA, colB);
return 0;
}
Enter the number of rows and columns for Matrix A: 3 3
Enter the number of rows and columns for Matrix B: 3 3
Input matrix A:
Enter elements of the matrix (3x3):
1 2 3
4 5 6
7 8 9
Input matrix B:
Enter elements of the matrix (3x3):
1 0 0
0 1 0
0 0 1
Matrix A:
1 2 3
4 5 6
7 8 9
Matrix B:
1 0 0
0 1 0
0 0 1
Resultant Matrix (A * B):
1 2 3
4 5 6
7 8 9
1. Write a program for finding the max and min from the three numbers. View Solution
2. Write the program for the simple, compound interest. View Solution
3. Write a program that prints a multiplication table for a given number and the number of rows in the table. View Solution
4. Write a program that shows the binary equivalent of a given positive number between 0 to 255. View Solution
1. Write a C program, which takes two integer operands and one operator from the user, performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement). View Solution
2. Write a program that finds if a given number is a prime number. View Solution
3. Write a C program to find the sum of individual digits of a positive integer and test given number is palindrome. View Solution
4. A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0 and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write a C program to generate the first n terms of the sequence. View Solution
1. Write a C program to find the minimum, maximum and average in an array of integers. View Solution
2. Write a C program that uses functions to perform Addition of two matrices. View Solution
3. Write a C program that uses functions to perform Multiplication of two matrices. View Solution
4. Write a program for reading elements using a pointer into an array and display the values using the array. View Solution
5. Write a program for display values reverse order from an array using a pointer. View Solution
1. Write a C program which copies one file to another, replacing all lowercase characters with their uppercase equivalents. View Solution
2. Write a C program to merge two files into a third file (i.e., the contents of the first file followed by those of the second are put in the third file). View Solution
1. Write a C program that uses functions to insert a sub-string into a given main string from a given position View Solution
2. Write a C program that uses functions to delete n Characters from a given position in a given string View Solution
3. Write a C program to determine if the given string is a palindrome or not (Spelled same in both directions with or without a meaning like madam, civic, noon, abcba, etc.) View Solution
4. Write a C program that displays the position of a character ch in the string S or – 1 if S doesn’t contain ch. View Solution
5. Write a C program to count the lines, words and characters in a given text. View Solution
1. Write a C program that uses non-recursive function to search for a Key value in a given list of integers using linear search method. View Solution
2. Write a C program that uses non-recursive function to search for a Key value in a given sorted list of integers using binary search method. View Solution
3. Write a C program that implements the Bubble sort method to sort a given list of integers in ascending order. View Solution
4. Write a C program that sorts the given array of integers using selection sort in descending orde. View Solution
5. Write a C program that sorts the given array of integers using insertion sort in ascending order. View Solution
6. Write a C program that sorts a given array of names. View Solution