Matrix Multiplication in C - Exercise 10 Solution: C Tutorial In Hindi #61

  Рет қаралды 211,869

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 134
@CodeWithHarry
@CodeWithHarry 5 жыл бұрын
I have created a second (English) channel and uploaded a brand new 2019 Python 3.7 Tutorial. Do Check out: kzbin.info/door/7btqG2Ww0_2LwuQxpvo2HQ
@usersanjeevkumar
@usersanjeevkumar 4 жыл бұрын
Rock Paper Scissors ka Source code aapne nhi diya hai...
@tanishchaudhary4496
@tanishchaudhary4496 3 жыл бұрын
Determinant using recursion in c as soon as possible
@SK-oo7vx
@SK-oo7vx Жыл бұрын
#include void display(int a[100][100],int b[100][100],int m,int n); void accept (int a[100][100],int m,int n); void add(int a[100][100], int b[100][100], int m, int n); void multiply(int a[100][100], int b[100][100],int m, int n); int main() { int a[100][100], b[100][100], m, n; printf(" How many rows and columns for both matrices? "); scanf("%d%d", &m, &n); printf(" Enter the matrix elements for first matrix : :"); accept(a, m, n); printf(" Enter the matrix elements for second matrix : "); accept(b, m, n); printf(" The matrix is : "); display(a,b,m,n); add(a, b, m, n); multiply(a, b, m, n); } void accept(int a[100][100], int m, int n) { int i, j; for(i = 0; i < m; i++) // outer loop fo rows // { for(j = 0;j < n; j++) // inner loop fo columns // { scanf("%d", &a[i][j]); } } } void display(int a[100][100],int b[100][100],int m ,int n) { int i, j; printf(" The elements of first matrix is %d by %d matrix are ",m,n); for(i = 0; i < m; i++) // outer loop fo rows // { for(j = 0;j < n; j++) // inner loop fo columns // { printf("%d\t", a[i][j]); } printf(" "); } printf(" The elements of second matrix is %d by %d matrix are ",m,n); for(i = 0; i < n; i++) // outer loop fo rows // { for(j= 0;j < m; j++) // inner loop fo columns // { printf("%d\t", b[i][j]); } printf(" "); } } void add(int a[100][100], int b[100][100], int m, int n) { int i, j; int add[100][100]; for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { add[i][j] = a[i][j] + b[i][j]; } } printf(" Addition Matrix is "); for(i = 0; i < m; i++) { printf(" "); for(j = 0; j < n; j++) { printf("%d\t",add[i][j]); } } } void multiply(int a[100][100], int b[100][100],int m, int n) { int i, j, k,sum; int multiply[100][100]; for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { multiply[i][j] = 0; for(k = 0; k < n; k++) { sum += a[i][k] * b[k][j]; } multiply[i][j]=sum; sum=0; } printf(" Multiplication Matrix is "); for(i = 0; i < m; i++) { printf (" "); for(j = 0; j < n; j++) { printf("%d\t",multiply[i][j]); } } } }
@SK-oo7vx
@SK-oo7vx Жыл бұрын
Sir this code is run properly but multiplication giving wrong in the output sir please can you correct this code
@Vickykumar-wn6nv
@Vickykumar-wn6nv Жыл бұрын
❤❤
@animeshsharma7332
@animeshsharma7332 5 жыл бұрын
I'm impressed by your consistency in uploading video, keep working it really helps.
@sayinsarkar8997
@sayinsarkar8997 2 жыл бұрын
jazaALLAH Harry bhaiii..(May Allah give u best reward)
@Ashish...114
@Ashish...114 Жыл бұрын
Very very thanks 👍🙏🙏🙏🙏
@bhagawangangane9287
@bhagawangangane9287 3 жыл бұрын
op bhai main programming ke sath sath maths bhi sikh gaya thank you so much
@nareshgoyal1994
@nareshgoyal1994 4 жыл бұрын
bro i have done this exercise using dynamic memory allocation in which a user types his own matrix of any rows and any column and it will multiply those matirx if mltipication is possible otherwise it will tell that multipication is not possible......................thanx for teaching me coding
@ViralXtreme
@ViralXtreme 4 жыл бұрын
Comment your code
@sallu_-bhai
@sallu_-bhai Жыл бұрын
Same me too
@SwarnadipDutta
@SwarnadipDutta 6 ай бұрын
@@ViralXtreme Here's is mine , almost works the same(note: some upgrades can be made such as freeing memory location for matrices should have been put under one function so that almost 30-40 lines can be cut off :) ) #include #include void take_matrix(int **a, int rows, int columns) { for (register int i = 0; i < rows; i++) { for (register int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = ", i + 1, j + 1); scanf("%d", (*(a + i) + j)); } } } void print_matrix(int **a, int rows, int columns) { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = %d ", i+1, j+1, *(*(a + i) + j)); } } } int main() { int a_rows, a_columns; printf("Enter the number of rows for matrix A : "); scanf("%d", &a_rows); int **a = (int **)malloc((a_rows) * sizeof(int *)); printf("Enter the number of columns for matrix A : "); scanf("%d", &a_columns); for (int i = 0; i < a_columns; i++) { *(a + i) = (int *)malloc((a_columns) * sizeof(int)); } printf(" "); int b_rows, b_columns; printf("Enter the number of rows for matrix B : "); scanf("%d", &b_rows); int **b = (int **)malloc((b_rows) * sizeof(int)); printf("Enter the number of columns for matrix B : "); scanf("%d", &b_columns); for (int i = 0; i < b_columns; i++) { *(b + i) = (int *)malloc((b_columns) * sizeof(int)); } if (((a != NULL && b != NULL) && (a_columns == b_rows))) { for (int i = 0; i < a_columns; i++) { if (*(a + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < a_columns; i++) { free(*(a + i)); } return 1; } } for (int i = 0; i < a_columns; i++) { if (*(b + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } return 1; } } printf(" "); printf("Enter matrix A elements : "); take_matrix(a, a_rows, a_columns); printf(" "); printf("Enter matrix B elements : "); take_matrix(b, b_rows, b_columns); int **result = (int **)malloc(a_rows * sizeof(int *)); for (int i = 0; i < b_columns; i++) { *(result + i) = (int *)calloc((b_columns), sizeof(int)); } if (result == NULL) { for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); return 1; } printf(" "); for (int i = 0; i < a_rows; i++) { for (int j = 0; j < b_columns; j++) { for (int m = 0; m < a_rows; m++) { result[i][j] += a[i][m] * b[m][j]; } } } printf("The multiplied matrix C = A*B is : "); print_matrix(result, a_rows, b_columns); for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); } if (a_columns != b_rows) { printf("No. of columns of matrix A and rows of matrix B must be the same. "); } for (int i = 0; i < a_columns; i++) { free(*(a + i)); } free(a); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } free(b); return 0; }
@aakash9025
@aakash9025 5 жыл бұрын
Awesome one bro 👊
@manasmathur173
@manasmathur173 11 ай бұрын
Great video very helpful , Thank You
@hito8391
@hito8391 5 жыл бұрын
You are a good explainer. Please make a node js tutorial
@2goldenchasma559
@2goldenchasma559 4 жыл бұрын
Love 💖💖 your teaching skills bro 👍👍
@Qubit313
@Qubit313 Жыл бұрын
Thankyou so much love from Pakistan! 🥰
@mandeepsinghbawa5272
@mandeepsinghbawa5272 5 жыл бұрын
Bhai please make videos on java script. BTW love you bhai
@royfamily9273
@royfamily9273 3 жыл бұрын
Thanks Harry Bhaiya
@aayushdhankecha1056
@aayushdhankecha1056 3 жыл бұрын
15:50 Matrix form me matrix kese enter ki thi ..... run hone ke bad ..... konsi keys ka use kiya tha ..... please anyone answer .......
@vanshshrivastava2325
@vanshshrivastava2325 3 жыл бұрын
bhai wo space ka use kiya, Harry bhai ne statement hatadi thi issi liye "enter the element " jaisa nahi aya aur input ek saath diya sabka "space ka use karke". 'Enter' aur 'space' dono work karte hai input ke time pe
@aayushdhankecha1056
@aayushdhankecha1056 3 жыл бұрын
@@vanshshrivastava2325 it is working .... Thank you so much bro ... 👍
@abhishekrawat8074
@abhishekrawat8074 2 жыл бұрын
But in the question, it was asked that we have to take input of number of rows and columns from the user. That was the main problem which I was facing, but I think concept of double pointers could be used here.
@umbkarai
@umbkarai 2 жыл бұрын
#include int main() { int k, l, m, n; int a[100][100], b[100][100], c[100][100]; printf("Enter the value of k "); scanf("%d", &k); printf("Enter the value of l "); scanf("%d", &l); printf("Enter the value of m "); scanf("%d", &m); printf("Enter the value of n "); scanf("%d", &n); printf("Enter the elements of matrix a : "); for (int i = 0; i < k; i++) { for (int j = 0; j < l; j++) { scanf("%d", &a[i][j]); } } printf("Enter the elements of matrix b : "); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { scanf("%d", &b[i][j]); } } printf("Matrix a is : "); for (int i = 0; i < k; i++) { for (int j = 0; j < l; j++) { printf("%d\t", a[i][j]); } printf(" "); } printf("Matrix b is : "); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { printf("%d\t", b[i][j]); } printf(" "); } if (l != m) { printf("Matrix Multiplication is not possible "); } else { for (int i = 0; i < k; i++) { for (int j = 0; j < n; j++) { for (int d = 0; d < l; d++) { c[i][j] += ((a[i][d]) * (b[d][j])); } } } printf("The final matrix adter multiplication of a and b is : "); for (int i = 0; i < k; i++) { for (int j = 0; j < n; j++) { printf("%d\t", c[i][j]); } printf(" "); } } return 0; }
@bhuvandahal421
@bhuvandahal421 2 жыл бұрын
#include int main() { int r1, c1, r2, c2, t; printf("Enter the no. of rows of matrix A: "); scanf("%d", &r1); printf("Enter the no. of columns of matrix A: "); scanf("%d", &c1); printf("Enter the no. of rows of matrix B: "); scanf("%d", &r2); printf("Enter the no. of columns of matrix B: "); scanf("%d", &c2); if(c1 == r2) { int A[r1][c1], B[r2][c2], C[r1][c2]; for(int i = 0; i < r1; i++) { for(int j = 0; j < c1; j++) { printf("Enter the value at (%d, %d) of matrix A: ", i, j); scanf("%d", &A[i][j]); } } for(int i = 0; i < r2; i++) { for(int j = 0; j < c2; j++) { printf("Enter the value at (%d, %d) of matrix B: ", i, j); scanf("%d", &B[i][j]); } } for(int i = 0; i < r1; i++) { for(int j = 0; j < c2; j++) { C[i][j] = 0; } } for(int i = 0; i < r1; i++) { for(int j = 0; j < c2; j++) { for(int k = 0; k < c1; k++) { t = A[i][k] * B[k][j]; C[i][j] += t; } } } printf("The matrix multiplication of A and B is given below: "); printf(" A * B = |"); for(int i = 0; i < r1; i++) { for(int j = 0; j < c2; j++) { printf(" %d ", C[i][j]); } printf("|"); if((i + 1) < r1) { printf(" |"); } } } else { printf("The matrix multiplication of A and B cannot be performed. "); } return 0; }
@SwarnadipDutta
@SwarnadipDutta 6 ай бұрын
I used dynamic memory allocation for the used matrices , otherwise the code can be wayyy shorter (dynamic memory allocation requires error handling a LOT) , also freeing matrices codes are repetitive so that can be put under a single void returning function(same as take_matrix() and print_matrix) #include #include void take_matrix(int **a, int rows, int columns) { for (register int i = 0; i < rows; i++) { for (register int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = ", i + 1, j + 1); scanf("%d", (*(a + i) + j)); } } } void print_matrix(int **a, int rows, int columns) { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = %d ", i+1, j+1, *(*(a + i) + j)); } } } int main() { int a_rows, a_columns; printf("Enter the number of rows for matrix A : "); scanf("%d", &a_rows); int **a = (int **)malloc((a_rows) * sizeof(int *)); printf("Enter the number of columns for matrix A : "); scanf("%d", &a_columns); for (int i = 0; i < a_columns; i++) { *(a + i) = (int *)malloc((a_columns) * sizeof(int)); } printf(" "); int b_rows, b_columns; printf("Enter the number of rows for matrix B : "); scanf("%d", &b_rows); int **b = (int **)malloc((b_rows) * sizeof(int)); printf("Enter the number of columns for matrix B : "); scanf("%d", &b_columns); for (int i = 0; i < b_columns; i++) { *(b + i) = (int *)malloc((b_columns) * sizeof(int)); } if (((a != NULL && b != NULL) && (a_columns == b_rows))) { for (int i = 0; i < a_columns; i++) { if (*(a + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < a_columns; i++) { free(*(a + i)); } return 1; } } for (int i = 0; i < a_columns; i++) { if (*(b + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } return 1; } } printf(" "); printf("Enter matrix A elements : "); take_matrix(a, a_rows, a_columns); printf(" "); printf("Enter matrix B elements : "); take_matrix(b, b_rows, b_columns); int **result = (int **)malloc(a_rows * sizeof(int *)); for (int i = 0; i < b_columns; i++) { *(result + i) = (int *)calloc((b_columns), sizeof(int)); } if (result == NULL) { for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); return 1; } printf(" "); for (int i = 0; i < a_rows; i++) { for (int j = 0; j < b_columns; j++) { for (int m = 0; m < a_rows; m++) { result[i][j] += a[i][m] * b[m][j]; } } } printf("The multiplied matrix C = A*B is : "); print_matrix(result, a_rows, b_columns); for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); } if (a_columns != b_rows) { printf("No. of columns of matrix A and rows of matrix B must be the same. "); } for (int i = 0; i < a_columns; i++) { free(*(a + i)); } free(a); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } free(b); return 0; }
@ajaybabupatel1665
@ajaybabupatel1665 3 жыл бұрын
GOOD PROGRAM
@BlackGokuX0
@BlackGokuX0 2 ай бұрын
16:44
@gamingangsuk4940
@gamingangsuk4940 2 жыл бұрын
I really excited for the next challenge 😁😁😁😁😉
@sumanmajumdar7884
@sumanmajumdar7884 2 жыл бұрын
13:51
@engineerbhai7642
@engineerbhai7642 5 жыл бұрын
Excellent
@officialgamer7433
@officialgamer7433 2 жыл бұрын
It's done: #include int main() { int m,n,p,q; printf("Enter the Value for row and column for first matrix: "); scanf("%d%d",&m,&n); printf("Enter the Value for row and column for second matrix: "); scanf("%d%d",&p,&q); if(n==p) { int A[m][n],B[p][q],i,j,k; printf("Enter elements for matrix A: "); for(i=0; i
@bvscode825
@bvscode825 5 жыл бұрын
Your vdos are awesome bro but i have a q on pointers why we should use pointer in real programming and how's it help us. plz if that possible. make a vdo on all pointers explain that. Tnx🙂🙂
@debodhkumar2905
@debodhkumar2905 4 жыл бұрын
because if you are writing your code in functions without the use of pointers then only one value can be returned .. but when you have to return more than one value then with the help of pointers multiple values can be returned ... for example if you have to swap two numbers then you have to use pointers in functions .. as you are returning two values which is (for eg. a and b ) .. i hope you got your answer
@bvscode825
@bvscode825 4 жыл бұрын
@@debodhkumar2905 ya bro tnx👍
@SwarnadipDutta
@SwarnadipDutta 6 ай бұрын
most popular use is to access the value of a local operator out of its scope
@hdchannel7430
@hdchannel7430 2 жыл бұрын
thankyou sir
@x-sss-x
@x-sss-x 4 жыл бұрын
nice boss
@chemistrylover9670
@chemistrylover9670 10 ай бұрын
What is the use of int m,n
@nehasinha6697
@nehasinha6697 3 жыл бұрын
wo last me input ka tarika change kaise kiya aapne straight line me teeno numbers ko input kaise kiya aapne ? Mai kar raha to 1 ke niche 2 uske niche 3 jaa raha. I really want to know 🤩
@princemaurya9717
@princemaurya9717 3 жыл бұрын
Same...pata chala ho to bta de yrr
@rivines
@rivines 3 жыл бұрын
i was trying it dynamoically in which we ask for the no. of rows and coloumns and then multiply both of them
@mohitverma5600
@mohitverma5600 3 жыл бұрын
Did it worked?? Whould u like to show me the resultant code 😁😁??
@corporateinfo_
@corporateinfo_ 2 жыл бұрын
here is the solution for multiplication of any two matrices (if possible). #include #include int main() { int a1,a2, b1,b2, sum = 0; printf("enter the order of the first matrix : i = "); scanf("%d", &a1); getchar(); printf("j = "); scanf("%d", &a2); getchar(); printf("enter the order of the second matrix : i = "); scanf("%d", &b1); getchar(); printf("j = "); scanf("%d", &b2); getchar(); int a[a1][a2]; int b[b1][b2]; int result [a1][b2]; if (a2 == b1) { printf("Enter the first matrix "); for (int i = 0; i < a1; i++) { for (int j = 0; j < a2; j++) { scanf("%d", &a[i][j]); } printf(" "); } printf("Enter the second matrix "); for (int i = 0; i < b1; i++) { for (int j = 0; j < b2; j++) { scanf("%d", &b[i][j]); } printf(" "); } printf("THE PRODUCT OF TWO MATRICES IS : "); for (int i = 0; i < a1; i++) { for (int j = 0; j < b2; j++) { for (int k = 0; k < a2; k++) { sum += a[i][k] * b[k][j]; } result[i][j] = sum; sum = 0; } } for (int i = 0; i < a1; i++) { for (int j = 0; j < b2; j++) { printf("%d \t", result[i][j]); } printf(" "); } } else { printf("THE TWO MATRICES CANNOT BE MULTIPLIED "); return 0; } return 0; }
@32solankikishan52
@32solankikishan52 Жыл бұрын
👍👍
@KashyapVinamra
@KashyapVinamra Жыл бұрын
Copy paste kar diye 😂
@gauravrawat8801
@gauravrawat8801 5 жыл бұрын
Sir m aur n variable kisliye bane the??
@NitinKumar-qk1fi
@NitinKumar-qk1fi 4 жыл бұрын
Complete👌💯👌💯👌💯👌💯👌💯👌💯👌💯
@devprakash6608
@devprakash6608 2 жыл бұрын
what is the meaning of this error? error: expected declaration specifiers or '...' before string constant
@sonitiwari2550
@sonitiwari2550 5 жыл бұрын
Bhai stick fighting game banao plz flash use karke your new subscriber from kanpur
@SoaibAslamOfficial
@SoaibAslamOfficial 2 жыл бұрын
Sheikh Soaib
@praffulmalkoti4407
@praffulmalkoti4407 5 жыл бұрын
Harry I have some doubts 1. Why don't you declare i and j.
@CodeWithHarry
@CodeWithHarry 5 жыл бұрын
I have declared i and j while writing the for loop for (int i = 0; i < 3; i++)
@roshtukuthiala3965
@roshtukuthiala3965 3 жыл бұрын
I am new to this course I watch all your videos and do all the exercises given by you But this program is taking too long to run it is not giving me output Also it does not show any error As when I run the same program on the other compiler it functions quickly
@tanishchaudhary4496
@tanishchaudhary4496 3 жыл бұрын
How to find determinant using recursion please 🙏🙏
@tusharsharma4234
@tusharsharma4234 Жыл бұрын
isse video ke end me aapne complicated kar diya
@falakm218
@falakm218 2 жыл бұрын
D=A+(B*C) matrix 3*3 kaise banega Harry Bhai....... previous year question m aaya tha mujhse solve ni ho rha h
@shabbirhabib9447
@shabbirhabib9447 3 жыл бұрын
you should've solved this excersice using dynamic memory allocation and would have taught us about double pointers
@moveonvillain1080
@moveonvillain1080 3 жыл бұрын
There are multiple ways for creating a 2D matrix using dynamic memory allocation not just double pointers method. The one I personally like is an array of pointers pointing to mem location in heap. Size of the array is the number of rows you want and size of the arrays that those pointers are pointing to in heap is the number of columns you want.
@svikash6464
@svikash6464 3 жыл бұрын
can you please send the code please............
@manojgurung4418
@manojgurung4418 4 жыл бұрын
harry bro apne paper scissors stone wala game achhe se solve nehi kiya aur ab is matrx wali problem ko bhi acche se solve nehi kiya
@ChetnThakre
@ChetnThakre Жыл бұрын
@Madanmohan-g5t
@Madanmohan-g5t Жыл бұрын
Why we do scanf later
@himanshukushwaha5064
@himanshukushwaha5064 2 жыл бұрын
harry bhai aapne ye nhi btaya tha size fix rahega I trying to make this program for any size it takes a lot of time
@PTLEGEND
@PTLEGEND 2 жыл бұрын
My input is not coming like last Plz suggest I had made same cod ebut why different in the terminal
@DeepakThakurEntrepreneur
@DeepakThakurEntrepreneur 3 жыл бұрын
Sorry To Say Brother But Aapk K Diye Gaye Source Code + Video Me Jo Bataye Hai Usss Tarha se First & Second Martix ..... Matrix Form Me Input nahi Hoti Hai Wo Bas Simple Form Me Input Hoti Hai .......
@amansatvilkar2093
@amansatvilkar2093 3 жыл бұрын
hoe to take input in that form, did you ge any logic?
@WildexZone
@WildexZone 3 жыл бұрын
Sir i have doubt in K variable . Why We have Take it?
@moveonvillain1080
@moveonvillain1080 3 жыл бұрын
see the explanation from 2:42 to 4:10
@achyutsavaliya2747
@achyutsavaliya2747 3 жыл бұрын
Moj kar dee
@manishkumaryadav2442
@manishkumaryadav2442 3 жыл бұрын
sir isme enter key buffer me kyo nahi ruka?? or isme humne getchar(); ka use kyo nahi kia?
@shubhamarya5005
@shubhamarya5005 5 жыл бұрын
Sir how to add a wishlist in your django e-commerce applications
@InsideSalesforce
@InsideSalesforce 3 жыл бұрын
Can anyone tell me " why we use += operator in this exercise"
@bhaveshjhawar9532
@bhaveshjhawar9532 3 жыл бұрын
"s += 4+1" suppose yeh kahi dia hua h ..simply it means s ko barabar krdo 5+s ke .... suppose hamara s pehle tha 1 toh now it is 6..... suppose s = 0 tha now it is 5.... got it ?
@rahulroy9731
@rahulroy9731 2 жыл бұрын
​@@bhaveshjhawar9532thanks bro
@pranavairsang9180
@pranavairsang9180 Жыл бұрын
#include void main() { int n1,m1,n2,m2,k,l=0; printf("Enter the number of rows and coloumns in the matrix 1 "); printf("Rows: "); scanf("%d",&n1); printf("Coloumns: "); scanf("%d",&m1); printf("Enter the number of rows and coloumns in the matrix 2 "); printf("Rows: "); scanf("%d",&n2); printf("Coloumns: "); scanf("%d",&m2); int a[n1][m1]; int b[n2][m2]; printf("Enter the elements of matrix 1: "); for (int i = 0; i < n1; i++) { for (int j = 0; j < m1; j++) { scanf("%d",&a[i][j]); } } for (int i = 0; i < n1; i++) { for (int j = 0; j < m1; j++) { printf("%d\t",a[i][j]); } printf(" "); } printf(" "); printf("Enter the elements of matrix 2: "); for (int i = 0; i < n2; i++) { for (int j = 0; j < m2; j++) { scanf("%d",&b[i][j]); } } for (int i = 0; i < n2; i++) { for (int j = 0; j < m2; j++) { printf("%d\t",b[i][j]); } printf(" "); } printf(" "); // printf("%d",a[1][1]*b[1][1]); if (m1==n2) { int c[n1][m2]; for (int i = 0; i < n1; i++) { for (int j = 0; j < m2; j++) { for( k=0;k
@saivigneshandalam
@saivigneshandalam 2 жыл бұрын
❤❤
@victorb22622
@victorb22622 9 ай бұрын
You did complicated ,if you made array thst woukd be better instead asking value of matrix
@BCAWala247
@BCAWala247 5 жыл бұрын
Bro please I am getting pyaudio error I tried many times but it is not getting installed .It gives setup.py building and failed... Please help me ....
@codewithswaraj6386
@codewithswaraj6386 3 жыл бұрын
Python uninstall kardao thik hojaga
@vishalborate9608
@vishalborate9608 2 жыл бұрын
scanf("%d",&a[i][j]); this statement i'm not understood, plz give me reply plz 🙏
@simranbains6199
@simranbains6199 2 жыл бұрын
bhai maths to sahi thi but c ke loops me i,j,k me ab bhi confusion hai
@eldrago3140
@eldrago3140 3 жыл бұрын
Wasn't the program to take the input from the users first for the number of rows and columns and if the rows and columns are not of the correct format then an error should be shown.
@jonnydhol9349
@jonnydhol9349 3 жыл бұрын
yeah you can easily do that , at the start of the program using if , printf and scanf
@pranavdeshmane9593
@pranavdeshmane9593 Жыл бұрын
@@jonnydhol9349it is easy to take input but the problem lies in code for matrix multiplication itself for e.g if u already know the matix row and col u can design code for that specific dimensions of matrix
@musicalrajput1047
@musicalrajput1047 5 жыл бұрын
Hlo bhai aapne C tutorial video main void type karke jo automatically jo aaya na syntax woh aa nahi raha hai mera? PLZ BATAO INSTA PAIN BHI AAP RELY NAHI DETE
@rishantsinha6963
@rishantsinha6963 3 жыл бұрын
Bro merey mai run ka option ni aa raha hai
@everythingofficial2264
@everythingofficial2264 5 жыл бұрын
undefined reference to winmain@16' collect2.exe error ld returned 1 exit status visual studio code sir plz solved i am in c
@shashank4640
@shashank4640 4 жыл бұрын
The input that I am giving is not showing in a matrix form, every element is coming in a new line. Please tell me how to fix this.
@rohitprasad1498
@rohitprasad1498 4 жыл бұрын
Yes, I am also getting the same problem. After copying the code from his site then still it is working in the line manner.
@shaharslan3372
@shaharslan3372 4 жыл бұрын
He's pressing enter after every 4 elements
@vanshshah7781
@vanshshah7781 3 жыл бұрын
Use \t
@manoor0858
@manoor0858 6 ай бұрын
challenge failed :( too complex for me
@Amith761
@Amith761 4 ай бұрын
Samaj mai nahi aya bhai 😢
@RohanDasRD
@RohanDasRD 5 жыл бұрын
First
@RohanDasRD
@RohanDasRD Жыл бұрын
@@InvinciRD Rice Field
@ishanchakraborty6658
@ishanchakraborty6658 Жыл бұрын
Carry minati
@PallabChatterjee18
@PallabChatterjee18 3 жыл бұрын
Where is the source code ?
@talish7714
@talish7714 3 жыл бұрын
bro maina to user define bana diya
@sudhanshu_31
@sudhanshu_31 Жыл бұрын
copy past kardiya not explain
@AryanSharma-zk6ql
@AryanSharma-zk6ql Жыл бұрын
Bhai ka ans do
@snehsingh933
@snehsingh933 5 жыл бұрын
#python ERROR: Could not find a version that satisfies the requirement speechRecoginition (from versions: none) ERROR: No matching distribution found for speechRecoginition i want to install speechRecoginition please help me
@indiangamersg2585
@indiangamersg2585 2 жыл бұрын
Bro to install speech recoginition moduel you first have to install a module named pyaudio. To install the pyaudio you have to watch one or two yt video because ir's very difficult to download it. I somehow managed to install both of them.
@ranojpayeng9313
@ranojpayeng9313 2 жыл бұрын
Ok
@Ashish...114
@Ashish...114 Жыл бұрын
bs multiply krne k baad wo 3rd loop ka idea nhi aa rha tha banki sb ku6 mene kr diya tha abb mene wo ek for loop add krke complete kr diya h& my program can multiply: 2x2 3x3 4x4 5x5 6x6.... & so on of any Matrix if it can be multiplied! #Solution: #include #include int main() { int r1, c1, r2, c2, sum = 0; printf("Welcome to the Matrix multiplication calulater: "); printf("Please enter the no. of rows in first matrix: "); scanf("%d", &r1); printf("Please enter the no. of columns in first matrix: "); scanf("%d", &c1); int A[r1][c1]; printf("Please enter the no. of rows in Second matrix: "); scanf("%d", &r2); printf("Please enter the no. of columns in Second matrix: "); scanf("%d", &c2); int B[r2][c2]; int C[r1][c2]; printf("You have choosen %dX%d and %dX%d matrix, ", r1, c1, r2, c2); if (c1 != r2) { printf("Your matrix cannot be multiplied."); goto end; } printf("Now: fill the first matrix- "); for (int k = 0; k < r1; k++) { for (int m = 0; m < c1; m++) { printf("row:%d and column:%d ", k, m); scanf("%d", &A[k][m]); } } printf("Now: fill the second matrix- "); for (int k = 0; k < r2; k++) { for (int m = 0; m < c2; m++) { printf("row:%d and column:%d ", k, m); scanf("%d", &B[k][m]); } } printf("Your first matrix let say 'A' is: "); for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { printf("%d\t", A[i][j]); } printf(" "); } printf("Your first matrix let say 'B' is: "); for (int i = 0; i < r2; i++) { for (int j = 0; j < c2; j++) { printf("%d\t", B[i][j]); } printf(" "); } printf("Here is your third matrix which is resultant of matrix A X matrix B "); printf(" Therefore, AXB = "); for (int i = 0; i < r1; i++) { for (int j = 0; j < c2; j++) { for (int k = 0; k < r1; k++) { sum += A[i][k] * B[k][j]; } C[i][j] = sum; sum = 0; } } for (int i = 0; i < r1; i++) { for (int j = 0; j < c2; j++) { printf("%d\t", C[i][j]); } printf(" "); } end: return 0; }
@ibeshkhadka
@ibeshkhadka 2 жыл бұрын
Kuch samajjj nahii aayaaaa Phir v thanks
@chandrabhanbahetwar9638
@chandrabhanbahetwar9638 3 жыл бұрын
Bhai tumne code run kiya to shi chl rha h but maine usko copy krke run kiya to mtrix shi nhi bn rhi
@woundman6521
@woundman6521 3 жыл бұрын
Same problem. Did u solved it? If Yes plz specify your doubt. Else if printf"0" ;
@Alwayspositive-pf1yf
@Alwayspositive-pf1yf 10 ай бұрын
Complexes program 😢
@jayshreeramforever
@jayshreeramforever Жыл бұрын
itni jldi krte ho samaj mai ya na aye
@santoshbhusal8432
@santoshbhusal8432 2 жыл бұрын
i have mistake in c program
@chandrabhanbahetwar9638
@chandrabhanbahetwar9638 3 жыл бұрын
Kuch glt h lg rha h
@chandrabhanbahetwar9638
@chandrabhanbahetwar9638 3 жыл бұрын
aayega khi
@gunmun2005
@gunmun2005 4 жыл бұрын
firBHI samajh nai aya
@LawSupportInsurance
@LawSupportInsurance Жыл бұрын
I dont know if you are still reading this comment or not... but the matrix multipication in the beginning that you tried to make us understand is not very complex as you showed.... Should have better Used numbers instead of variables..... Anyways great video helping me so far...... 61th Video im watching from the beginning of the series
@sallu_-bhai
@sallu_-bhai Жыл бұрын
#include int row1, column1, row2, column2; int main(int argc, char const *argv[]) { printf("Enter size of Row 1: "); scanf("%d", &row1); printf("Enter size of column 1: "); scanf("%d", &column1); printf("Enter size of Row 2: "); scanf("%d", &row2); printf("Enter size of column 2: "); scanf("%d", &column2); int a[row1][column1], b[row2][column2]; for (int i = 0; i < row1; i++) { for (int j = 0; j < column1; j++) { printf("Enter row %d and column %d : ", i + 1, j + 1); scanf("%d", &a[i][j]); } } printf(" Now input 2nd matrix "); for (int i = 0; i < row2; i++) { for (int j = 0; j < column2; j++) { printf("Enter row %d and column %d : ", i + 1, j + 1); scanf("%d", &b[i][j]); } } if (column1 != row2) { printf("Matrix multiplication is possible only if column of 1st matrix is equal to row of second matrix"); } else { int c[column1][row2]; for (int i = 0; i < column1; i++) { for (int j = 0; j < row2; j++) { c[i][j] = 0; for (int k = 0; k < column2; k++) { c[i][j] += a[i][k] * b[k][j]; } } } for (int i = 0; i < column1; i++) { for (int j = 0; j < row2; j++) { printf("%d ", c[i][j]); } printf(" "); } } return 0; }
@ramansinghthakur2216
@ramansinghthakur2216 2 жыл бұрын
i need your help harry sir how can i contact you .....?????
@tanmay_b_07
@tanmay_b_07 7 ай бұрын
solution 21-06-24 //tany #include int main() { int a, b, c, d, sum=0; printf("please input rows of first matrix:"); scanf("%d", &a); printf("please input column of first matrix:"); scanf("%d", &b); printf("please input rows of second matrix:"); scanf("%d", &c); printf("please input column of second matrix:"); scanf("%d", &d); int arr[a][b]; int array[c][d]; if (b == c) { for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { printf("Enter the %d%d element of first matrix:", i + 1, j + 1); scanf("%d", &arr[i][j]); } } printf("********************************************* "); for (int i = 0; i < c; i++) { for (int j = 0; j < d; j++) { printf("Enter the %d%d element of second matrix:", i + 1, j + 1); scanf("%d", &array[i][j]); } } int array2[a][d]; for (int i = 0; i < a; i++) { for (int j = 0; j < d; j++) { for (int k = 0; k < b; k++) { sum += (arr[i][k] * array[k][j]); } array2[i][j]=sum; sum=0; } } printf(" the result is "); for (int i = 0; i < a; i++) { for (int j = 0; j < d; j++) { printf("%d",array2[i][j]); if(j
@CodeVerse562
@CodeVerse562 5 ай бұрын
#include #include // Title: Matrix multiplication int main() { // Rows and columns of matrix int r1, c1, r2, c2; printf("Enter rows in 1st matrix: "); scanf("%d", &r1); getchar(); printf("Enter columns in 1st matrix: "); scanf("%d", &c1); getchar(); printf(" Enter rows in 2nd matrix: "); scanf("%d", &r2); getchar(); printf("Enter columns in 2nd matrix: "); scanf("%d", &c2); getchar(); printf(" "); // Declaring the matrix int matrix1[r1][c1], matrix2[r2][c2]; // Entering the value of 1st matrix printf("Enter value of 1st matrix... "); for (int i = 0; i < r1; i++) { for (int k = 0; k < c1; k++) { printf("Enter %d, %d element: ", i, k); scanf("%d", &(matrix1[i][k])); getchar(); } } printf(" "); // Entering the value of 2nd matrix printf("Enter value of 2nd matrix... "); for (int i = 0; i < r2; i++) { for (int k = 0; k < c2; k++) { printf("Enter %d, %d element: ", i, k); scanf("%d", &(matrix2[i][k])); getchar(); } } int resultingmatrix[r1][c2]; for (int i = 0; i < r1; i++) { for (int k = 0; k < c2; k++) { resultingmatrix[i][k] = 0; } } if (c1 != r2) { printf("Matrix can't be multiply... "); } else { // Calculating the values of resulting matrix for (int i = 0; i < r1; i++) { for (int k = 0; k < c2; k++) { for (int j = 0; j < c1; j++) { resultingmatrix[i][k] += (matrix1[i][j] * matrix2[j][k]); } } } } // Showing the resulting matrix printf(" The resulting matrix is this... "); for (int i = 0; i < r1; i++) { for (int k = 0; k < c2; k++) { printf("%d ", resultingmatrix[i][k]); } printf(" "); } return 0; }
@varunkolanu
@varunkolanu 2 жыл бұрын
#include int main() { int m1,n1,m2,n2; printf(" Let 1st matrix be A and 2nd matrix be B "); printf("Enter the no. of rows in matrix A: "); scanf("%d",&m1); printf("Enter the no. of columns in matrix A: "); scanf("%d",&n1); printf("Enter the no. of rows in matrix B: "); scanf("%d",&m2); printf("Enter the no. of columns in matrix B: "); scanf("%d",&n2); if(n1!=m2) { printf(" The matrices can't be multiplied"); printf(" since no.of columns in A should be equal to no.of rows in B"); } else { printf(" "); printf("Aij means element of matrix A in ith row and jth column "); printf("Bij means element of matrix B in ith row and jth column "); int A[m1][n1], B[m2][n2]; printf("Enter the values of A: "); for(int i=0;i
@SwarnadipDutta
@SwarnadipDutta 6 ай бұрын
#include #include void take_matrix(int **a, int rows, int columns) { for (register int i = 0; i < rows; i++) { for (register int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = ", i + 1, j + 1); scanf("%d", (*(a + i) + j)); } } } void print_matrix(int **a, int rows, int columns) { for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { printf("Element no.(%d,%d) = %d ", i+1, j+1, *(*(a + i) + j)); } } } int main() { int a_rows, a_columns; printf("Enter the number of rows for matrix A : "); scanf("%d", &a_rows); int **a = (int **)malloc((a_rows) * sizeof(int *)); printf("Enter the number of columns for matrix A : "); scanf("%d", &a_columns); for (int i = 0; i < a_columns; i++) { *(a + i) = (int *)malloc((a_columns) * sizeof(int)); } printf(" "); int b_rows, b_columns; printf("Enter the number of rows for matrix B : "); scanf("%d", &b_rows); int **b = (int **)malloc((b_rows) * sizeof(int)); printf("Enter the number of columns for matrix B : "); scanf("%d", &b_columns); for (int i = 0; i < b_columns; i++) { *(b + i) = (int *)malloc((b_columns) * sizeof(int)); } if (((a != NULL && b != NULL) && (a_columns == b_rows))) { for (int i = 0; i < a_columns; i++) { if (*(a + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < a_columns; i++) { free(*(a + i)); } return 1; } } for (int i = 0; i < a_columns; i++) { if (*(b + i) == NULL) { printf("Not enough memory! "); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } return 1; } } printf(" "); printf("Enter matrix A elements : "); take_matrix(a, a_rows, a_columns); printf(" "); printf("Enter matrix B elements : "); take_matrix(b, b_rows, b_columns); int **result = (int **)malloc(a_rows * sizeof(int *)); for (int i = 0; i < b_columns; i++) { *(result + i) = (int *)calloc((b_columns), sizeof(int)); } if (result == NULL) { for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); return 1; } printf(" "); for (int i = 0; i < a_rows; i++) { for (int j = 0; j < b_columns; j++) { for (int m = 0; m < a_rows; m++) { result[i][j] += a[i][m] * b[m][j]; } } } printf("The multiplied matrix C = A*B is : "); print_matrix(result, a_rows, b_columns); for (int i = 0; i < b_columns; i++) { free(*(result + i)); } free(result); } if (a_columns != b_rows) { printf("No. of columns of matrix A and rows of matrix B must be the same. "); } for (int i = 0; i < a_columns; i++) { free(*(a + i)); } free(a); for (int i = 0; i < b_columns; i++) { free(*(b + i)); } free(b); return 0; }
@realism2463
@realism2463 2 жыл бұрын
Fully explained ---> #include int main(int argc, char const *argv[]) { int r1, r2, c1, c2, sum = 0; printf("Enter no. of rows of first matrix : "); scanf("%d", &r1); printf("Enter no. of rows of second matrix : "); scanf("%d", &r2); printf("Enter no. of column of first matrix : "); scanf("%d", &c1); printf("Enter no. of column of second matrix : "); scanf("%d", &c2); int matrixA[r1][c1], matrixB[r2][c2], product_matrix[r1][c2]; for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { printf("a[%d][%d] = ", i, j); scanf("%d", &matrixA[i][j]); } } for (int i = 0; i < r2; i++) { for (int j = 0; j < c2; j++) { printf("a[%d][%d] = ", i, j); scanf("%d", &matrixB[i][j]); } } printf(" Matrix A = "); for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { printf("%d ", matrixA[i][j]); } printf(" "); } printf("Matrix B = "); for (int i = 0; i < r2; i++) { for (int j = 0; j < c2; j++) { printf("%d ", matrixB[i][j]); } printf(" "); } for (int i = 0; i < r1; i++) { for (int j = 0; j < c2; j++) { for (int n = 0; n < r2; n++) { sum += matrixA[i][n] * matrixB[n][j]; } product_matrix[i][j] = sum; sum = 0; } } printf("Matrix after multiplication = "); for (int i = 0; i < r1; i++) { for (int j = 0; j < c2; j++) { printf("%d ", product_matrix[i][j]); } printf(" "); } return 0; }
File I/O In C: C Tutorial In Hindi #62
8:27
CodeWithHarry
Рет қаралды 117 М.
Arrays In C: C Tutorial In Hindi #23
25:45
CodeWithHarry
Рет қаралды 1,1 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
C_60 C program for Matrix Multiplication part 1 | C Language Tutorials
12:21
Jenny's Lectures CS IT
Рет қаралды 222 М.
C Program for Matrix Multiplication (Part 2)
8:19
Neso Academy
Рет қаралды 483 М.
C_59 Program to add Two Matrix in C | C language tutorials
17:26
Jenny's Lectures CS IT
Рет қаралды 345 М.
Web Developer Roadmap (2025) - Everything is Changing
21:48
CodeWithHarry
Рет қаралды 468 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 2,7 МЛН
Путин ответил на ультиматум Трампа
7:25
Diplomatrutube
Рет қаралды 1,9 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН