Write a c program to accept an m*n matrix and find the largest and smallest number from the matrix using dynamic memory allocation.
#includevoid main() { int **ip,i=0,j=0; int m,n,max=0,min=0; clrscr(); printf("\n enter the m and n\n"); scanf("%d%d",&m,&n); ip=(int**)malloc(m*sizeof(int)); for(i=0;iip[i]=(int*)malloc(n*sizeof(int)); printf("\n enter the array elements\n"); for(i=0;i{ for(j=0;j{ scanf("%d",&ip[i][j]); } } printf("\n enter array elements\n"); for(i=0;i{ for(j=0;j{ printf("\t%d",ip[i][j]); } printf("\n"); } max=ip[0][0]; min=ip[0][0]; for(i=0;i{ for(j=0;j{ if(max{ max=ip[i][j]; } if(min>ip[i][j]) { min=ip[i][j]; } } } printf("\n max=%d \n min=%d",max,min); getch(); } /*------------------------------output---------------------------- enter the m and n 2 3 enter the array elements 4 5 7 9 4 3 enter array elements 4 5 7 9 4 3 max=9 min=3 */
Write a c program to accept an m*n matrix and find the largest and smallest number from the matrix using dynamic memory allocation.
Reviewed by
on
April 24, 2015
Rating: