This is a C program. The file is arrayTable.txt. Write a program that creates a
ID: 665991 • Letter: T
Question
This is a C program.
The file is arrayTable.txt.
Write a program that creates a two-dimensional array in the heap and then analyzes it to determine the minimum, maximum, and average of each column. The data are to be read from a file. The first two elements are the number of rows in the array and the number of columns in each row. The file data for a 12 x 8 array are shown below.
in the heap and ·Write a program that creates a two-dimensional array in the he then analyzes it to determine the minimum, maximum, and a each column. and average of The data are to be read from a file. The first two elements are the number of rows in the array and the number of columns in each row. The file data for a 12 × 8 array are shown below. 12 838 758 113 515 51 627 10 419 212 86 749 767 84 60 225 543 89 183 137 566 966 978 495 311 367 54 31 145 882 736 524 505 394 102 85 67 754 653 561 96 628 188 85 143 967 406 165 562 834 353 920 444 803 962 422 327 457 945 479 983 751 670 259 248 757 629 306 606 738 516 414 262 116 825 181 343 22 233 536 760 979 336 61 160 165 403 962 318 894 990 134 201 993 71 5 729 644 475 19. Rewrite the atuu:Explanation / Answer
#include<stdio.h>
void main()
{
FILE *ptr;
int m,n,i,j,a[20][20],sum,min,max;
float avg;
clrscr();
ptr=fopen("myfile.txt","r");
fscanf(ptr,"%d",&m);
fscanf(ptr,"%d",&n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
fscanf(ptr,"%d",&a[i][j]);
}
}
for(i=0;i<m;i++)
{
sum=0;
avg=0.0;
min=999;
max=0;
for(j=0;j<n;j++)
{
sum=sum+a[i][j];
if(a[i][j] <min)
min=a[i][j];
if(a[i][j]>max)
max=a[i][j];
}
avg=sum/n;
printf("Minimum value in %d row is %d ",i,min);
printf("Maximum value in %d row is %d ",i,max);
printf("Average = %f ",avg);
printf(" ");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.