//WAP to multiplication of two 2x2 matrix. #include<stdio.h> #include<conio.h> void main() { int i,j,k,a[2][2],b[2][2],c[2][2],sum; clrscr(); printf("Enter any element of 1st matrix:\n"); for(i=0;i<2;i++) { for(j=0;j<2;j++) scanf("%d",&a[i][j]); } printf("Entre any element of 2nd matrix:\n"); for(i=0;i<2;i++) { for(j=0;j<2;j++) scanf("%d",&b[i][j]); } //Multiplication logic for(i=0;i<2;i++) { sum=0; for(k=0;k<2;k++) { sum = sum + a[i][k] * b[i][j]; c[i][j]=sum; } } printf("Result matrix:"); for(i=0;i<2;i++) { for(j=0;j<2;j++) printf("%d\t",c[i][j]); printf("\n"); } getch(); }
// WAP to enter three numbers and find middle number among them. #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( ( a > b && a < c ) || ( a > c && a < b ) ) printf ( "%d is middle number" , a ) ; else if ( ( b > a && b < c ) || ( b > c && b < a ) ) printf ( "%d is middle number" , b ) ; else printf ( "%d is middle number" , c ) ; getch ( ) ; } Output:
Comments
Post a Comment