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 Prinf Copy With Square Of 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 square(int a[10][10],int b[10][10],int r,int c)


{
int i,j;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
b[i][j]=a[i][j]*a[i][j];
}
}
}

int main()
{
int i,r,c,a[10][10],b[10][10];
FILE *fp;
clrscr();
fp=fopen("Z:\\squarearray.txt","w");
if(fp==NULL)
{
printf("File Could Not Open");
exit (0);
}
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);
square(a,b,r,c);
printf("\n\nSquare Of Matrix");
fprintf(fp,"\n\nSquare Of Matrix");
printf("\n");
fprintf(fp,"\n");
display_array(b,r,c,fp);
getch();
return 0;
}
/* OUTPUT:
Enter Size Of Row::2
Enter Size Of Column::2
Matrix Of Array ::
Enter Value [0][0] 1
Enter Value [0][1] 2
Enter Value [1][0] 3
Enter Value [1][1] 4
1 2
3 4
Square Of Matrix
1 4
9 16
*/

You might also like