Tuesday, January 31, 2012

RESULT MANAGEMENT SYSTEM


#include<stdio.h>
#include<conio.h>
void add();
void view();
FILE *fp;
int i,ch;
struct student
{char name[20];
int math,phy,cse,eng;
char grade;
int roll_no;};
struct student s;
void main()
{
clrscr();
printf("\n>>>>>>>>>>>>  RESULT MANAGEMENT SYSTEM  <<<<<<<<<<<<");
printf("\n **************MENU*****************");
printf("\n 1 for add");
printf("\n 2 for viewing the result=");
printf("\nenter your choice");
scanf("%d",&ch);
switch(ch)
 {case 1:
  add();
  break;
  case 2:
  view();
  break;
  default:
  printf("wrong input");
  }
 getch();
 }


void add()

{

fp=fopen("result.txt","a");
printf("enter record of student number ");
scanf("%s %d %d %d %d %d %c",s.name, &s.roll_no, &s.math,&s.phy, &s.cse, &s.eng, &s.grade);
fprintf(fp," \n%s\t %d\t %d\t %d\t %d\t %d\t %c",s.name, s.roll_no,s.math,s. phy, s.cse, s.eng, s.grade);
printf("record added successfuly");
fclose(fp);
}
void view()


{ fp=fopen("result.txt","r");
for(i=0;i<=30;i++)
{
fscanf(fp,"%s %d %d %d %d %d %c",s.name, &s.roll_no,&s.math,&s.phy,&s.cse,&s.eng,&s.grade);
printf("\n name=%s\troll_no=%d\tmath=%d\tphy=%d\tcse=%d\teng=%d\t grade=%c",s.name,s.roll_no,s.math,s.phy,s.cse,s.eng,s.grade);
}
fclose(fp);
}

No comments:

Post a Comment