-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submit C Code with Explanation #5
Comments
Ashim Bhadra |
/******************************************************************************
Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> void main() }} /reading second matrix/
} //coded by Arun paneru (o76BCT009) < b> Explanation: The above source code is to multiply two mxn and pxq matrices entered by user. |
#include<stdio.h> void main()
} #Explanation... An array is itslef a internal pointer which represent base address of the array. i.e if x is a 1-D array then address of fist element is expressed as &x[0] either *x and for second element x[2] or (x+1) and so on. so in above program pointer array a,band pr is declared( int (*a)(n).... which are equivalent to "int a[m][n].....). And the for printing and calculating equivalent array pointer value notation is used. |
//WAP to multiply two matrix using pointer// #include<stdio.h> if(p!=n){ for(i=0;i<m;i++){ } The above program is about multiplication of two matrix mn and pq using pointer. For this we initialize two pointer array a and b ,then we ask the number of row and column of the matrix and if the column of first matrix is not equal to the row of second matrix then we cannot continue the operation ,else we ask the element of first matrix and second matrix. Like in the simple matrix multiplication ,we can write The main operation for the matrix multiplication using pointer is |
Explanation: &a[i][j]= *(a+i)+j and a[i][j]= *(&a[i][j]) = ((a+i)+j) is the main logic behind this code. Other than this, the matrix multiplication has been carried out in the standard way(rows of first matrix multiplied to the columns of the second matrix). The matrix is multiplied and displayed in the same nested loop by initializing the matrix (in which the result is stored) multiple times at the beginning of every loop. Created by: Asutosh K. Sedai, KCE076BCT011 |
This program multiplies two matrices whose order is gives by the user in the form of (Mxn) and (pxq). This is equivalent way for the multiplication of two given matrices using pointer. |
Submitted by: Shopnil Shrestha |
Explanation: BY: AAJU PRAJAPATI |
#include<stdio.h>
} EXPALANATION:- |
Explanation : |
This is the matrices multiplication using pointer. |
#include<stdio.h> int main(){ Explanation: |
//Explanation : |
The above program multiplies two matrices using the concept of pointer. At first three 2D int arrays and seven normal integers. The dimension for matrix a and b are read and fed into integers m,n and p,q respectively. If n is not equal to p then it displays "Invalid message" and the user is asked to re-enter the dimensions. And then matrix mul is displayed.
This is because array itself is an Thus, matrix multiplication can be done using these concept of pointer and arrays. Submitted by: |
here for the matrix multiplication first of all the size of matrix is asked from user. as inthe simple matrix multiplication , a[i][j] = ((a+i)+j), thus matrix multiplication is done using concept of pointer. |
Discussion:In the above program, multiplication of two matrices is done using pointers. Here we used following general notations of pointers in the above program. |
#include<stdio.h> void main() int i,j,k,m,n,p,q; if(n!=p){ for (i=0;i<m;i++) for(i=0; i<m; i++) Explanation: Name: Saman Chaugathi |
The above program helps to multiply a matrices of mn & pq where values of 'm','n','p' and 'q' are taken from keyboard using scanf function. A pointer is a variable that contain memory address instead of values. syntax of pointer: data_type *variable_name; array declaration ------------> equivalent pointer declaration And the for printing and calculating equivalent array pointer value notation is used. The main formula used to multiply is: |
#include <stdio.h>
} Explanation |
#include<stdio.h> void main() { if(n != p) {
getch(); Explanation
|
#include <stdio.h> /* Explanation: |
#include <stdio.h> void main(){ printf("Enter the order of matrix 1 :");
printf("\nEnter the order of matrix 2 :"); if(O!=N){ for (i = 0; i < O; i++)
//multiplication part
//display result
} Explanations:
|
//Explanation
//Suyan Shrestha |
#include<conio.h> void main(){ printf("enter the element of matrix A:"); } EXPLANATION: |
first of all the integer variables are defined. Then the user is asked to enter the row and column of the two matrices. |
multiplication.txt |
The text was updated successfully, but these errors were encountered: