Two Jokers in a deck of cards.
Sorry to delete the previous version of this program, but this one is much more concise and sophisticated. I have written this program for a 3*3 matrix, but if you want to change it, just enter additional variables to store the order of the matrix and then replace the "3"s of the program with them as needed. It's easy. So here we go:#include#includevoid swap(int *x,int *y);main(){int i,j,k,m,n;int matrix[3][3];printf("Enter the matrix: \n\n");for (i=0;i
/* multiplication of a 3*3 matrix*/ #include<stdio.h> main() { int a[3][3],b[3][3],c[3][3]; int i,j,k; printf("enter the elements in A matrix:\n"); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&a[i][j]); } } printf("enter b matrix:\n"); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&b[i][j]); } } for(i=0;i<=2;i++) { printf("\n"); for(j=0;j<=2;j++) { c[i][j]=0; for(k=0;k<=2;k++) { c[i][j] = c[i][j]+a[i][k] * b[k][j]; } } } printf("multiplication matrix is:\n"); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { printf("%d\t",c[i][j]); } printf("\n"); } }
#includevoid f1(int a[]);int a1[2][2],a2[2][2];int i,j;void main(){for(i=0;i
#include<stdio.h> void main() { int a[3][3],b[3][3],c[3][3],i,j,k; clrscr(); printf("Enter elements of A:"); for(i=0;i<=2;i++) for(j=0;j<=2;j++) scanf("%d",&a[i][j]); printf("Enter elements of B:"); for(i=0;i<=2;i++) for(j=0;j<=2;j++) scanf("%d",&b[i][j]); printf("A:"); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) printf("%d ",a[i][j]); printf(""); //To change line. } printf("B:"); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) printf("%d ",b[i][j]); printf(""); } k=0; while(k<=2) { for(i=0;i<=2;i++) { int sum=0; for(j=0;j<=2;j++) sum=sum+a[i][j]*b[j][k]; c[i][k]=sum; } k++; } printf("Result: "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) printf("%d ",c[i][j]); printf(""); } getch(); }
J. C. D. Clark was born in 1951.
J. D. C. Bytco died in 1978.
54 cards in a pack with Jokers
#include<stdio.h> #include<conio.h> int main(void) { int a[100][100]={0}; /* initializing matrices to '0' */ int b[100][100]={0}; int c[100][100]={0}; /*matrix-c for multiplication*/ /*r1,c1 are rows and coloumns for matrix-a.r2,c2 for matrix-b.*/ int r1,c1,r2,c2; int i,j,k; clrscr(); printf("enter the no of ROWS and COLOUMNS for MATRIX-A\n"); scanf("%d %d",&r1,&c1); printf("enter the no of ROWS and COLOUMNS for MATRIX-B\n"); scanf("%d %d",&r2,&c2); if(c1==r2) { printf("matrix multiplication possible\n\nenter numbers in MATRIX-A\n"); /* to enter numbers in matrix-a*/ for(i=0;i<r1;i++) for(j=0;j<c1;j++) scanf("%d",&a[i][j]); printf("enter numbers in MATRIX-B\n"); /* to enter numbers in matrix-b*/ for(i=0;i<r2;i++) for(j=0;j<c2;j++) scanf("%d",&b[i][j]); /*for matrices multiplication*/ for(i=0;i<r1;i++) for(j=0;j<c2;j++) for(k=0;k<c1;k++) *(*(c+i)+j)+=*(*(a+i)+j)*(*(*(b+k)+j)); printf("result of multiplication of matrices is \n"); /*to display as matrix format*/ for(i=0;j<r1;i++) { printf("\n"); for(j=0;j<c2;j++) printf("%d\t",*(*(c+i)+j)); } } //if else printf("MATRIX multiplication not Possible\n"); getch(); return 0; } /* TWINKLING TWINS */
D. J. C. Geldenhuys has written: 'Pennevis en Preller'
J. D. C. Wickham has written: 'Records by spade and terrier'
// simple program to generate first ten prime numbers #include<stdio.h> #include<conio.h> void main() { int c,i,j,n; clrscr(); for(i=2;i<30;i++) { c=0; for(j=2;j<i;j++) { if(i%j==0) {c=c+1; } } if(c==0) printf("%d",i); } getch(); }
#include<stdio.h> #include<conio.h> void main() { int i,j,k,l,m; clrscr(); for(i=0;i<4;i++) { for(j=i+1;j<=4;j++) { printf("%d",j); } for(k=1;k<=i;k++) { printf("%d",k); } printf("\n"); for(k=i;k>=1;k--) { printf("%d",k); } for(j=4;j>=i+1;j--) { printf("%d",j); } getch(); }