look in a maths dictionary
#include<stdio.h> #include<conio.h> void main()
void avg() { for(i=0;i<=No of employers;i++) { avg=avg+salary[i]; } printf("%d",avg); } void maths() { void avg(); } use this function call v can call when v need to calculate avg.
DataStructure-Program to transpose a sparse matrix.#include #include #include #define MAX1 3#define MAX2 3struct sparse{int *sp ;int row ;} ;void initsparse ( struct sparse * ) ;void create_array ( struct sparse * ) ;void display ( struct sparse ) ;int count ( struct sparse ) ;void create_tuple ( struct sparse *, struct sparse ) ;void display_tuple ( struct sparse ) ;void transpose ( struct sparse *, struct sparse ) ;void display_transpose ( struct sparse ) ;void delsparse ( struct sparse * ) ;void main( ){struct sparse s[3] ;int c, i ;for ( i = 0 ; i sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ;for ( i = 0 ; i < MAX1 * MAX2 ; i++ ){printf ( "Enter element no. %d:", i ) ;scanf ( "%d", &n ) ;* ( p -> sp + i ) = n ;}}/* displays the contents of the matrix */void display ( struct sparse s ){int i ;/* traverses the entire matrix */for ( i = 0 ; i < MAX1 * MAX2 ; i++ ){/* positions the cursor to the new line for every new row */if ( i % MAX2 0 )printf ( "\n" ) ;printf ( "%d\t", * ( p.sp + i ) ) ;}}/* deallocates memory */void delsparse ( struct sparse *p ){free ( p -> sp ) ;}
# include<stdio.h> void display(int [][3]); void main() { int c; void func1(); void func2(); void func3(); void func4(); void func5(); clrscr(); printf("\n- : Matrix Manipulation Functions (for 3 X 3 Matrix) : -"); printf("\n-------------------------------------"); printf("\n Matrix Addition : 1"); printf("\n Matrix Subtraction : 2"); printf("\n Matrix Multiplication : 3"); printf("\n Find Transpose Matrix : 4"); printf("\n Matrix is Symmetric or not : 6"); printf("\n Enter Your Choice : "); scanf("%d",&c); switch(c) { case 1: func1(); break; case 2: func2(); break; case 3: func3(); break; case 4: func4(); break; case 5: func5(); break; default: printf("\nInvalid Choice"); } getch(); } void func1() { int x[3][3],y[3][3],z[3][3]; void getmatrix(int [][3]); void addition(int [][3],int [][3],int [][3]); clrscr(); getmatrix(x); getmatrix(y); addition(x,y,z); printf("\n - : Matrix 1: - \n"); display(x); printf("\n - : Matrix 2: - \n"); display(y); printf("\n - : Matrix Addition (Result): - \n"); display(z); } void getmatrix(int t[][3]) { int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("Enter element [%d][%d] : ",i,j); scanf("%d",&t[i][j]); } } } void addition(int p[][3],int q[][3],int r[][3]) { int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) r[i][j]=p[i][j]+q[i][j]; } } void func2() { int x[3][3],y[3][3],z[3][3]; void getmatrix(int [][3]); void subtraction(int [][3],int [][3],int [][3]); clrscr(); getmatrix(x); getmatrix(y); subtraction(x,y,z); printf("\n - : Matrix 1: - \n"); display(x); printf("\n - : Matrix 2: - \n"); display(y); printf("\n - : Matrix Subtraction (Result): - \n"); display(z); } void subtraction(int p[3][3],int q[3][3],int r[3][3]) { int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) r[i][j]=p[i][j]-q[i][j]; } } void func3() { int x[3][3],y[3][3],z[3][3]; void getmatrix(int [][3]); void multiplication(int [][3],int [][3],int [][3]); clrscr(); getmatrix(x); getmatrix(y); multiplication(x,y,z); printf("\n - : Matrix 1: - \n"); display(x); printf("\n - : Matrix 2: - \n"); display(y); printf("\n - : Matrix Multiplication (Result): - \n"); display(z); } void multiplication(int p[][3],int q[3][3],int r[3][3]) { int i,j,k; for(i=0;i<3;i++) //condition i< total row of matrix1 { for(j=0;j<3;j++) //condition i< total col of matrix1 or//condition i< total row of matrix2 { r[i][j]=0; for(k=0;k<3;k++) //condition i< total col of matrix2 r[i][j]=r[i][j]+(p[i][j]*q[j][k]); } } } void func4() { int x[3][3],y[3][3]; void getmatrix(int [][3]); void transpose(int [][3],int [][3]); clrscr(); getmatrix(x); transpose(x,y); printf("\n - : Matrix 1: - \n"); display(x); printf("\n - : Transpose Matrix : - \n"); display(y); } void transpose(int p[][3],int q[][3]) { int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) q[i][j]=p[j][i]; } } void func5() { int x[3][3],y[3][3]; void getmatrix(int [][3]); void transpose(int [][3],int [][3]); int symmetric(int [][3],int [][3]); clrscr(); getmatrix(x); transpose(x,y); if(symmetric(x,y)==1) printf("\nMatrix is Symmetric"); else printf("\nMatrix is Not Symmetric"); } int symmetric(int p[][3],int q[][3]) { int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(q[i][j]!=p[i][j]) return 0; } } return 1; } void display(int m[][3]) { int i,j; printf("\n\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d ",m[i][j]); printf("\n"); } }
#include <stdio.h> #define MAX1 3 #define MAX2 3 struct sparse { int *sp ; int row ; } ; void initsparse ( struct sparse * ) ; void create_array ( struct sparse * ) ; void display ( struct sparse ) ; int count ( struct sparse ) ; void create_tuple ( struct sparse *, struct sparse ) ; void display_tuple ( struct sparse ) ; void transpose ( struct sparse *, struct sparse ) ; void display_transpose ( struct sparse ) ; void delsparse ( struct sparse * ) ; void main( ) { struct sparse s[3] ; int c, i ; for ( i = 0 ; i <= 2 ; i++ ) initsparse ( &s[i] ); create_array ( &s[0] ) ; printf ( "\nElements in Sparse Matrix: " ) ; display ( s[0] ) ; c = count ( s[0] ) ; printf ( "\n\nNumber of non-zero elements: %d", c ) ; create_tuple ( &s[1], s[0] ) ; printf ( "\n\nArray of non-zero elements: " ) ; display_tuple ( s[1] ) ; transpose ( &s[2], s[1] ) ; printf ( "\n\nTranspose of array: " ) ; display_transpose ( s[2] ) ; for ( i = 0 ; i <= 2 ; i++ ) delsparse ( &s[i] ); } /* initialises data members */ void initsparse ( struct sparse *p ) { p -> sp = NULL ; } /* dynamically creates the matrix of size MAX1 x MAX2 */ void create_array ( struct sparse *p ) { int n, i ; p -> sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ; for ( i = 0 ; i < MAX1 * MAX2 ; i++ ) { printf ( "Enter element no. %d:", i ) ; scanf ( "%d", &n ) ; * ( p -> sp + i ) = n ; } } /* displays the contents of the matrix */ void display ( struct sparse s ) { int i ; /* traverses the entire matrix */ for ( i = 0 ; i < MAX1 * MAX2 ; i++ ) { /* positions the cursor to the new line for every new row */ if ( i % MAX2 0 ) printf ( "\n" ) ; printf ( "%d\t", * ( p.sp + i ) ) ; } } /* deallocates memory */ void delsparse ( struct sparse *p ) { free ( p -> sp ) ; }
No. To find the second-order ranking (second-order dominance vector, V2), you add each of the columns and it will give you a (how ever many rows) x 1 matrix.
for(int i=0;i
In Algebra, the word determinant is a special number which is associated to any square matrix. Like for example, a rectangular array of numbers where the finite number of rows and columns are equal. Therefore, the meaning of a determinant is a scale factor for measuring wherever the matrix is regarded.
It is a table of items, usually numbers. For example, you might consider the prices of several items in a shop. Put these in a column. Then for the same items in a different shop, another column alongside the first. And several shops. You finish up with an array of prices. That is an example of a matrix.
4.(Displaying matrix of 0s and 1s ) write a method that displays by n by n matrix using the following header : Public static void printMatrix(int n) Each element is o or 1,which is generated randomely. Write a test program that prints a 3 by 3 matrix that may look like this: 010 000 111 4.(Displaying matrix of 0s and 1s ) write a method that displays by n by n matrix using the following header : Public static void printMatrix(int n) Each element is o or 1,which is generated randomely. Write a test program that prints a 3 by 3 matrix that may look like this: 010 000 111
Transpose means swap places. In maths, the term is usually used for matrices. It means truning the matrix around so that its rows become columns and columns become rows.