#include #include #include #include /* Written By : Ahmad Jawed ZAFAR Date : 15/02/2008 Program Name : Calculates Exam Result */ int main() { FILE *fptr; int i, j, st_no, les_no; char temp[25], slct; time_t lt; lt = time(NULL); printf(ctime(<)); printf("\n"); struct exam { char *name; int mark[15], total; } student[50],t; fptr=fopen("data.txt","w"); /* writes into the data.txt file */ printf(" *** Programmed By ZAFARSOFT ***\n"); printf("\n"); printf("Enter Total Number Of Students, Maximum 50 : "); scanf("%d", &st_no); printf("\n"); printf("Now Enter Total Number Of Lessons, Maximum 15 : "); scanf("%d", &les_no); printf("\n"); gets(temp); for (i=0; i Name\n", i+1); gets(temp); student[i].name=(char*)malloc(strlen(temp)*sizeof(char)); strcpy(student[i].name, temp); printf("Now Enter Student < %d > or < %s > Marks\n", i+1, student[i].name); student[i].total=0; for (j=0; j Total Mark Of < %s > Is < %d > \n", i+1, student[i].name, student[i].total); printf("------------------------------------------------------|\n"); } printf("\n"); printf("Do You Want To Write The Result In A Text File (Y/N) \n"); scanf("%c",&slct); if (slct == 'y' || slct == 'Y') { for (i=0; i Total Mark Of < %s > Is < %d > \n", i+1, student[i].name, student[i].total); /* writes into the data.txt file */ } } fclose(fptr); system("pause"); return 0; }