# 6 Use the function structure to a C program to read 2 D floating ma

Content type
User Generated
Rating
Showing Page:
1/5
6. Use the function structure to a C program to read 2-D
floating matrix from then calculate its average. Note:
Assume that the matrix size is 5 by 5.
Solution
Average.c
#include <stdio.h>
void readArray(float a[][5], int row, int col);
int main()
{
float a[5][5];
return 0;
}
void readArray(float a[][5], int row, int col){
int i, j;
float avg;
for(i=0; i<row; i++){
for(j=0;j<col;j++){
printf(\"Enter Value : \ \");
scanf(\"%f\", &a[i][j]);

Showing Page:
2/5
}
}
printf(\"Input Array is : \ \");
for(i=0; i<row; i++){
for(j=0;j<col;j++){
printf(\"%f \", a[i][j]);
}
printf(\"\ \");
}
printf(\"Average is : \ \");
for(i=0; i<row; i++){
for(j=0;j<col;j++){
avg = avg + a[i][j];
}
}
printf(\"%f\", (avg/(5*5)));
}
Output:
Enter Value :
1
Enter Value :
2
Enter Value :
3

Showing Page:
3/5

End of Preview - Want to read all 5 pages?
Access Now
Unformatted Attachment Preview
6. Use the function structure to a C program to read 2 -D floating matrix from then calculate its average. Note: Assume that the matrix size is 5 by 5. Solution Average.c #include void readArray(float a[][5], int row, int col); int main() { float a[5][5]; readArray(a, 5, 5); return 0; } void readArray(float a[][5], int row, int col){ int i, j; float avg; for(i=0; i ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Just what I was looking for! Super helpful.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4