#include <stdio.h> main() { int m, n, c, d, A[10][10],temp=0; printf("\nEnter the number of rows and columns for matrix A:\n"); scanf("%d%d", &m, &n); printf("\nEnter the elements of matrix A:\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &A[c][d]); printf("\nMatrix entered is:\n"); for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < n ; d++ ) printf("%d\t", A[c][d]); printf("\n"); } printf("\n\nMaximum element of each row is:\n"); for(c=0;c<m;c++) { for(d=0;d<n;d++) { if(A[c][d]>temp) temp=A[c][d]; } printf("\n\t\tRow %d: %d",c+1,temp); temp=0; } temp=A[0][0]; printf("\n\nMinimum element of each coloumn is:\n"); for(c=0;c<n;c++) { for(d=0;d<m;d++) { if(A[d][c]<temp) temp=A[d][c]; } printf("\n\t\tColoumn %d: %d",c+1,temp); temp=A[d][c] ; } return 0; }
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
#include<stdio.h> #include<conio.h> void main() { int a[3][3],b[3][3],c[3][3],r,c; for(r=0;r<=3;r++) { for(c=0;c<3;c++) { printf("\n enter the value="); scanf("%d%d",&a[r][c],&b[r][c]); } } printf("\n first matrix=\n"); for(r=0;r<=3;r++) { for(c=0;c<3;c++) { printf("%d\t",a[r][c]); } printf("\n"); } printf("\n scond matrix=\n"); for(r=0;r<=3;r++) { for(c=0;c<3;c++) {printf("%d\t",b[r][c]); } printf("\n"); } printf("\n sum of given matrix=\n"); for(r=0;r<=3;r++) { for(c=0;c<3;c++) { c[r][c]=a[r][c]+b[r][c]; printf("%d\t",c[r][c]); } printf("\n"); } getch(); }
#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}
/*WAP to display Fibonacci series*/ #include<stdio.h> #include<conio.h> void main() { int i,a=0,b=1,c; scanf("%d",&n); printf("%d\n%d",a,b); for(i=0;i<n;i++) { c=a+b; a=b; b=c; printf("\n%d",c); } getch(); }
#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}
Nothing can be Divided to 0
#include<stdio.h> #include<conio.h> main() { int a[10][10],b[10][10],c[10][10],m,n,i,j,p,q,op; printf("enter the order of matrix a:n"); scanf("%d",&m,&n); printf("enter the %d elements of a\n",m*); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); printf("enter the order of matrix b:n"); scanf("%d",&p,&q); printf("enter the %d elements of b\n",p*q); for(i=0;i<p;i++) for(j=0;j<q;j++) scanf("%d",&b[i][j]); printf("enter the option\n"); scanf("%d",&option); switch(op) { case '+' : if(m==p&&n==q) printf("the resultant matrix c is:\n"); for(i=0;i<m;i++) for(j=0;j<n;j++) c[i][j]=a[i][j]+b[i][j]; printf("%d",c[i][j]); printf("\n"); break; case '/' : if(n==p) { for(i=0;i<m;;i++); {for(j=0;j<q;j++) {printf("%d",c[i][j]); } } c[i][j]=0; for(p=0;p<n;p++) c[i][j]=c[i][j]+a[i][p]*b[p][j]: } printf("resultant matrix is:\n"); for(i=0;i<m;;i++); {for(j=0;j<q;j++) {printf("%d\t",c[i][j]); } } printf("\n"); getch(); }
#include<stdio.h> main() { int a=0,b=1,n,c,i; printf("enter number"); scanf("%d",&n); printf("%d\n",a); for(i=1;i<=n;i++) { c=a+b; printf("%d\n",c); b=a; a=c; } getch(); }
if (n>0) printf ("%d is positive\n", n);
[ Fibonacci series___: ] #include<stdio.h> int main(void) { int n,i,c,a=0,b=1; printf("Enter Fibonacci series of nth term : "); scanf("%d",&n); printf("%d %d ",a,b); for(i=0;i<=(n-3);i++) { c=a+b; a=b; b=c; printf("%d ",c); } }
#include<stdio.h> #include<conio.h> void main() { clrscr(); int m[10][10]; int i,j,r,c; for (i=0;i<10;i++) { for (j=0;j<10;j++) { m[i][j]=0; } } printf("\n Enter size of row and colomn:"); scanf("%d %d",&r,&c); printf("\n Enter the two matrices: \n"); for (i=0;i<r;i++) { for (j=0;j<c;j++) { printf("Enter element %d %d of m1: ",(i+1),(j+1)); scanf("%d",&m[i][j]); } } printf("\n The matrix is: \n"); for (i=0;i<r;i++) { for (j=0;j<c;j++) { printf("%d ",m[i][j]); } printf("\n"); } printf("\n The transpose of the matrix is: \n"); for (i=0;i<r;i++) { for (j=0;j<c;j++) { printf("%d ",m[j][i]); } printf("\n"); } getch(); }