If I do
Code:#include <stdio.h> float ave(float stu[][3][4]); float sAve(float stu[][4]); int main() { int i, j, k; float stu[2][3][4]; for(i=0; i<2; i++){ for(j=0;j<3;j++){ for(k=0; k<4; k++){ if(k==0){ printf("Enter in the grade for student %d in subject %d", j+1, k+1); scanf("%d", &stu[i][j][k]); }else scanf("%d", &stu[i][j][k]); } } } printf("All Averages: %f", ave(stu)); printf("Student Averages: %f", sAve(stu)); } float ave(float stu[][3][4]) { float sum=0; int i, j, k; for(i=0; i<2; i++){ for(j=0;j<3;j++){ for(k=0; k<4; k++){ sum+=stu[i][j][k]; } } } return (sum/24); } float sAve(float stu[][4]) { float sum=0, l=3, m=4; int i, j; for(i=0; i<2; i++){ for(j=0;j<3;j++){ sum+=stu[i][j]; } } return (sum/12); }
C:\Users\J\Desktop\gcc Lab8a.c -o Lab8a
Lab8a.c: In function 'main':
Lab8a.c:29:1: warning: passing argument 1 of 'sAve' from incompatible pointer ty
pe [enabled by default]
Lab8a.c:9:7: note: expected 'float (*)[4]' but argument is of type 'float (*)[3]
[4]'



LinkBack URL
About LinkBacks



