You are on page 1of 2

/* ROLL NO: 1 SEM-1 ICA DIV: A

NAME : VARUN AGGARWAL SUBJECT: FOP


PROGRAM DEFINITION:Write a program to Find Maximum in Matrix.. .
*/

#include<stdio.h>
#include<conio.h>

void read_array(int a[10][10],int r,int c)


{
int i,j;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("Enter Value [%d][%d]\t",i,j);
scanf("%d",&a[i][j]);
}
printf("\n");
}
}

void display_array(int a[10][10],int r,int c,FILE *fp)


{
int i,j;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
fprintf(fp,"%d\t",a[i][j]);

}
printf("\n");
fprintf(fp,"\n");
}
}

void maxmatrix(int a[10][10],int r,int c,FILE *fp)


{
int i,j,max=a[0][0];
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if(a[i][j]>max)
{
max=a[i][j];
}
}
}
printf("\n\nMaximun is %d",max);
fprintf(fp,"\n\nMaximun is %d",max);

int main()
{
int i,r,c,a[10][10];
FILE *fp;
clrscr();
fp=fopen("Z:\\minmatrix.txt","w");
if(fp==NULL)
{
printf("File Could Not Open");

}
printf("Enter Size Of Row::");
scanf("%d",&r);
printf("Enter Size Of Column::");
scanf("%d",&c);
printf("\nMatrix Of Array ::\n\n");
fprintf(fp,"\nArray One\n\n");
read_array(a,r,c);
display_array(a,r,c,fp);
maxmatrix(a,r,c,fp);
getch();
return 0;
}
/* OUTPUT:
Enter Size Of Row::3
Enter Size Of Column::3
Matrix Of Array ::
Enter Value [0][0] 12
Enter Value [0][1] 25
Enter Value [0][2] 12
Enter Value [1][0] 24
Enter Value [1][1] 52
Enter Value [1][2] 45
Enter Value [2][0] 85
Enter Value [2][1] 32
Enter Value [2][2] 52
12 25 12
24 52 45
85 32 52
Maximun is 85

*/