Sunday, December 9, 2012

WAP to find largest value from Matrix using UDF 49


#include<stdio.h>
#include<conio.h>
void max();
void main()
{


 clrscr();
  max();
 getch();
}
void max(void)
{
int a[100][100],c,d,r,i,j;
printf("enter matrix:");
printf("\nhow many column enter in matrix:");
scanf("%d",&c);
printf("\nhow many row enter in matrix:");
scanf("%d",&r);
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
 printf("a[%d][%d]:",i,j);
 scanf("%d",&a[i][j]);
}
}
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
 printf("%d\t",a[i][j]);

}
printf("\n");
}
d=a[0][0];
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
 if(d<a[i][j])
 {
d=a[i][j];
 }
}
}
printf("\n maximum is %d",d);


}

No comments:

Post a Comment