answersLogoWhite

0

  1. #include
  2. #include
  3. FILE *fp;
  4. sturct student
  5. {
  6. int a,r;
  7. char n[10];
  8. float p;
  9. }s;
  10. main()
  11. {
  12. int response;
  13. clrscr();
  14. fp=fopen("file1.dat","w+");
  15. while(1)
  16. {
  17. printf("\nInput data from keyboard to write to file\n");
  18. printf("input name ");
  19. scanf("%s",s.n);
  20. printf("\nInput roll no.,age and percentage ");
  21. scanf("%d%d%f",&s.r,&s.a,&s.p);
  22. fprintf(fp,"%s%d%d%f",s.n,s.r,s.a,s.p);
  23. printf("\nAnother record 1:yes, 0:no ");
  24. scanf("%d",&response);
  25. if(response==0)
  26. break;
  27. }
  28. rewind(fp);
  29. printf("\nDate storeed in file is\n");
  30. printf("\nName\tRollNo.Age\tPer.\n");
  31. while(!feof(fp))
  32. {
  33. scanf(fp,"%s%d%d%f",s.n,&s.r,&s.a,&s.p);
  34. printf("\n%s\t%d\t%d\t%f",s.n,s.r,s.a,s.p);
  35. }
  36. fclose(fp);
  37. }
User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How can write a c program to store students record in a file?

Write a console based C++ program that reads student information from a text file, build an array of objects of type class StudentInfo,


How can I have a mobile application for my online store done?

You would have to pay a computer programmer to write an application program for your store.


Which MS software is used to store large amount of records?

Database ***** Microsoft Access is the database program.


Is it more efficient to store the data in a matrix then write it to the file at the end of the program or to write each element to the file as the program runs?

It shouldn't make significant difference, only if the matrix is huge -- in that case you shouldn't store it in memory.


What are work study programs?

A work study program is a program which helps college students pay for the cost of their education. Students work at various jobs, such as at the college book store, to earn money to help them get through school.


Write a c program to accept name and store the name in its short form?

happy birthday...


Write a program to accept name and store the name in it's short form as eg sikkim manipal university SMU?

Write a program to accept name and store the name in its short form (e.g. Sikkim Manipal University should be stored as SMU)


When was Aquarius Records - store - created?

Aquarius Records - store - was created in 1970.


What objects does Access store records?

Records are stored in tables.


How do you write pet store in possessive form?

If you are speaking of a store that belongs to pets, then you would write: pet's store


What are store records?

yes, it is correct


How do you write a program in C that will captures details The details to be captured are student name mark and age The program should calculate and display the average marks for all the students?

Create a data structure to store the details for each student: typedef struct student_t { char name[30]; unsigned age; unsigned mark; } student; Establish an array to store the student data: size_t max = 100; // replace 100 with the actual number of students student students[max]; Use a loop to enter the data: for (size_t i=0; i<max; ++i) { printf ("Student name: "); scanf ("%s", students[i].name); printf ("Student age: "); scanf ("%u", students[i].age); printf ("Student mark: "); scanf ("%u", students[i].mark); } Calculate and display the average mark: unsigned sum = 0; for (size_t i=0; i<max; ++i) sum += student[i].mark; printf ("Average mark: %d\n", sum / max_students);