//WAP to read element of two 2x2 matrix and perform addition #include<stdio.h> #include<conio.h> void main() { int i,j,a[2][2],b[2][2],c[2][2]; 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]); } for(i=0;i<2;i++) { for(j=0;j<2;j++) c[i][j]=a[i][j]+b[i][j]; } printf("Element of Result matrix:"); for(i=0;i<2;i++) { for(j=0;j<2;j++) printf("%d\t",c[i][j]); } 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