GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.

WRITE A C-PROGRAM TO FIND THE BIGGEST&SMALLEST NUMBER OF THE GIVEN MATRIX.
AIM:A program to find the biggest and smallest number of a given matrix.
PROGRAM:
#include<stdio.h>
main()
{
int a[10][10],i,j,m,n,big,small;
printf("enter the values of m,n");
scanf("%d%d",&m,&n);
printf("enter the elemnts of matrix a");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
big=a[0][0];
small=a[0][0];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(a[i][j]>big)
big=a[i][j];
if(a[i][j]<small)
small=a[i][j];
printf("biggest element =%d",big);
printf("smallest element =%d",small);
}
OUTPUT:
enter the values of m,n
3,3
enter the elements of matrix a
1 2 3
3 4 5
5 6 7
biggest element 7
smallest element 1

No comments:

Post a Comment