//Write a C program to print the sum of a sparse matrix.(Data Structure)
#include
#include
int i,j,k,l,m,m1,m2,n1,n2,nz1=0,nz2=0,z1=0,z2=0,sm1[3][50],sm2[3][50],
a[100][100],b[100][100],sm3[3][50];
void main()
{
clrscr();
printf("\n\n\n\t\t FIRST MATRIX");
printf("\n\nENTER THE VALUE FOR ROW = ");
scanf("%d",&m1);
printf("\n\nENTER THE VALUE FOR COLUMN= ");
scanf("%d",&n1); clrscr();
printf("\n\nENTER THE VALUE FOR (%d*%d) MATRIX= ",m1,n1); for(i=0;inz1) printf("\n\n\nIT CAN CONVERT INTO SPARSE MATRIX\n"); else { printf("\n\nCAN'T CONVERT INTO SPARSE MATRIX\n"); exit(1); } //converting into sparse matrix printf("\n\nCONVERSION OF SPARSE MATRIX\n\n"); sm1[0][0]=m1; sm1[0][1]=n1; sm1[0][2]=nz1; k=1; for(i=0;inz2) printf("\n\n\nIT CAN CONVERT INTO SPARSE MATRIX\n"); else { printf("\n\nCAN'T CONVERT INTO SPARSE MATRIX\n"); exit(1); } //converting into sparse matrix printf("\n\nCONVERSION OF SPARSE MATRIX\n\n"); sm2[0][0]=m2; sm2[0][1]=n2; sm2[0][2]=nz2; l=1; for(i=0;i=m2&&n2) { sm3[0][0]=m1; sm3[0][1]=n1; sm3[0][2]=nz1+nz2; } else { sm3[0][0]=m2; sm3[0][1]=n2; sm3[0][2]=nz1+nz2; } k=1,l=1,m=1; while(nz1!=0&&nz2!=0) { if(sm1[k][0]==sm2[l][0]&&sm1[k][1]==sm2[l][1]) { sm3[k][0]=sm1[k][0]; sm3[k][1]=sm1[k][1]; sm3[k][2]=sm1[k][2]+sm2[k][2]; k++; l++; m++; nz1++; nz2++; } //printing of addition OS sparse matrix printf("\n\n\t\tADDTION OF SPARSE MATRIX IS\n\n"); for(i=0;i
This is a directive, not a question.
http://www.assignmentsclub.com/
matrix
Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.
#include <stdio.h> #include <conio.h> void main() { int d[3][3] = { 1, 2, 6, 3, 8, 5, 5, 6, 7 }; int k = 0, j = 0; int sum1 = 0, sum2 = 0; for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) printf(" %3d", d[j][k]); printf("\n"); } for (j = 0; j < 3; j++) { sum1 = sum1 + d[j][j]; } k = 3 - 1; for (j = 0; j < 3; j++) { if (k >= 0) { sum2 = sum2 + d[j][k]; k--; } } printf("Sum of First diagonal= %d\n", sum1); printf("Sum of Second diagonal= %d", sum2); getch();
#include
printf("%s",per>50?:"pass",per<50?:"fail");
i cant write
wap to print all the arnstrong no. between 100&1000
5 CLS 10 REM PROGRAM TO ADD FIRST 7 EVEN NUMBERS 20 EV = 2 30 SUM = 0 35 PRINT "NUMBERS="; 40 FOR I = 1 TO 7 50 SUM = SUM + EV 55 PRINT EV; 60 EV = EV + 2 70 NEXT I 95 PRINT 80 PRINT "SUM="; SUM 90 END http://arnavguddu.6te.net/
ring me and ill explain - 086 22222222222222227 ring me
C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion