#include <stdio.h> #define ROWS 3 #define COLS 3 void matrixMultiply(int *mat1, int *mat2, int *result, int rows1, int cols1, int cols2) { int i, j, k; // Multiplying matrices for (i = 0; i < rows1; i++) { for (j = 0; j < cols2; j++) { *(result + i * cols2 + j) = 0; for (k = 0; k < cols1; k++) { *(result + i * cols2 + j) += *(mat1 + i * cols1 + k) * *(mat2 + k * cols2 + j); } } } } void displayMatrix(int *mat, int rows, int cols) { int i, j; // Displaying matrix for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { printf("%d\t", *(mat + i * cols + j)); } printf("\n"); } } int main() { int mat1[ROWS][COLS] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int mat2[ROWS][COLS] = {{9, 8, 7}, {6, 5, 4}, {
Write a C program (use a switch statement for selection) to add or subtract 2 matrices having order 3 x 3, depending upon the choice made by the user
Write a C program (use a switch statement for selection) to add or subtract 2 matrices having order 3 x 3, depending upon the choice made by the user. MCS-011 : PROBLEM SOLVING AND PROGRAMMING (June, 2017) c program for matrix operations using switch case, c program for addition and subtraction of two matrices, algorithm for matrix addition in c program #include <stdio.h> #include<conio.h> void main() { int first_matrix[3][3], second_matrix[3][3], sub_of_two_matrix[3][3],sum_of_two_matrix[3][3], i, j; int oprater; clrscr(); //Enter First Matrix printf("\nEnter elements of 1st matrix:\n"); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { printf("Enter element a%d%d: ", i + 1, j + 1); scanf("%d", &first_matrix[i][j]); } //Enter Second Matrix printf("Enter elements of 2nd matrix:\n"); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { printf("Enter element
Ignou result tottaly destroyed the futureπππππ
ReplyDeletehmmmm
DeleteIS THERE NO SOLN OF LAB FOR BCSL 13 , 21 , 22 , 32 , 33 , 34 , 43 , 44 , 45 , MCSL016 FROM 2014 TILL JUNE 2018
Delete