#include<stdio.h>
#include<string.h>
float avg(float);
main()
{
FILE *p[2];
int k,students=10,subjects=4,i,j,id_number,date_of_birth,fail=0;
float marks[100],total=0,avg;
char name[30],course_enrolled[30],filename[10];
for(i=1;i<=2;i++)
{
printf("filename");
scanf("%s",&filename);
p[i]=fopen(filename,"w");
printf("Enter Name of Student\n",p[i]);
fscanf(stdin,"%s",&name,p[i]);
printf("Enter Course In Which Student Is Enrolled\n",p[i]);
fscanf(stdin,"%s",&course_enrolled,p[i]);
printf("Enter ID Number Of %s Enrolled in Course %s\n",name,course_enrolled,p[i]);
fscanf(stdin,"%d",&id_number,p[i]);
printf("Enter Date Of Birth Of %s Enrolled in Course %s and\n ID-Number is %d\n",name,course_enrolled,id_number,p[i]);
fscanf(stdin,"%d",&date_of_birth,p[i]);
for(j=1;j<=4;j++)
{
printf("Enter Marks for Subject %d for Student %s\n",j,name);
fscanf(stdin,"%f",&marks[j]);
total=total+marks[j];
if(marks[j]<50)
fail=fail+1;
else
continue;
}
avg=(total/400)*100;
printf("AVERAGE=%f\n",avg);
if(avg>=70)
printf("Grade A\n");
if(avg>=60&avg<70)
printf("Grade B\n");
else if(avg>=50&avg<60)
printf("Grade C\n");
else if(avg>=45&avg<50)
printf("Grade D\n");
else if(avg>=40&avg<45)
printf("Grade E\n");
else if(avg<40)
printf("Fail\n");
if(fail>=2)
printf("Student is failed and cann;t promote\n");
else
continue;
fclose (p[i]);
}
for(k=1;k<=2;k++)
{
printf("Input filename");
scanf("%s",&filename);
p[k]=fopen(filename,"r");
fprintf(stdout,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %d\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,avg);
fclose (p[k]);
}
getch();
}
there is a problem i cann;t save all data in a single file as well as but cann;t use array of pointers in function to save records of 10 students