Write a "main" function that takes the number of students (less than or equal to 100)and the passing grade from the keyboard and sends this information to the "calculate" function. The "calculate" function will read grades of each student from the keyboard and record them in an array with 100 elements.According to the passing grade, find out how many students failed and return it from function, and print the class average on the function. Accordingly, write "main" and "calculate" functions in the following fields.
Kod:
#include<stdio.h>
#define MAX 100
int hesapla(int dizi[],int sayi,int k)
{
if(k==-1){
if(sayi<=0){
return 0;
}
return (dizi[sayi-1]+hesapla(dizi,sayi-1,-1)*(sayi-1))/sayi;
}
else{
if(sayi<=0){
return 0;
}
else{
if(dizi[sayi-1]<50){
k++;
}
return k + hesapla(dizi,sayi -1 ,0);
}}}
int main(){
int s;
int dizi[MAX];
printf("ogrenci sayisini giriniz \n");
scanf("%d",&s);
for(int i=0;i<s;){
printf("%d.notlari giriniz \n",i+1);
scanf("%d",&dizi[i]);
i++;
}
printf("ortalma:%d",hesapla(dizi,s,-1));
printf("kalanlar:%d",hesapla(dizi,s,0));
}
}
Moderatör tarafında düzenlendi: