Mark Sheet

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mark Sheet as PDF for free.

More details

  • Words: 474
  • Pages: 4
#include <stdio.h> main() { FILE *f1; char ch; printf("Data Input\n\n"); f1=fopen("Student marksheet.txt","w"); if ( (fopen( "Student marksheet.txt", "w" ) ) == NULL ) printf ("This file cannot be opened"); else printf ("THE FILE IS SUCESSFULLY OPENED"); struct personal { char name[20]; char birthday[15]; int id; char course [10]; }; { struct personal person; printf("input values\n"); scanf("%s %s %d %s",&person.name,&person.birthday,&person.id,&pers on.course); printf("%s %s %d %s\n",person.name,person.birthday,person.id,person .course); fprintf(f1,"%s %s %d %s\n",person.name,person.birthday,person.id,person .course); } int n, m, i, j,t,s,roll_number, marks, total; float average; printf("enter number of students and subjects\n"); fprintf(f1,"enter number of students and subjects"); scanf("%d %d",&n,&m); for(i=1;i<=10;i++); { printf("Enter roll_number"); fprintf(f1,"Enter roll_number"); scanf("%d",&roll_number); total=0; printf("\n Enter marks of %d subjects for roll No.%d \n",m,roll_number); fprintf(f1,"\n Enter marks of %d subjects for roll No.%d \n",m,roll_number); for(j=1;j<=4;j++) { scanf ("%d",&marks); total=total+marks; } average=total/m; printf("Total marks=%4d",total); fprintf(f1,"Total marks=%4d",total); printf("average=%f\n", average); fprintf(f1,"average=%f\n", average);

if (average>=70) printf("Grade A\n\n"); fprintf(f1,"Grade A\n\n"); else if (average>=60) (here it is saying syntax error before else. and same afterwards, i marked it in red colour) printf("Grade B \n\n"); fprintf(f1,"Grade B\n\n"); else if (average>=50) printf ("Grade C \n\n"); fprintf(f1,"Grade C\n\n"); else if (average>=45) printf("Grade D\n\n"); fprintf(f1,"Grade D\n\n"); else if (average>=40) printf("Grade E\n\n"); fprintf(f1,"Grade E\n\n"); else printf("(***Fail***)"); fprintf(f1,"(***Fail***)"); fclose(f1); } getch(); } So basically if i remove the red coloured lines i will be able to get the results

/////////////////////////////// 1. #include <stdio.h> 2. 3. main() 4. { 5. FILE *f1; 6. char ch; 7. 8. printf("Data Input\n\n"); 9. f1=fopen("Student marksheet.txt","w"); 10. 11. if ( (fopen( "Student marksheet.txt", "w" ) ) == NULL ) 12. printf ("This file cannot be opened"); 13. else 14. printf ("THE FILE IS SUCESSFULLY OPENED"); 15. 16. struct personal 17. { 18. char name[20]; 19. char birthday[15]; 20. int id; 21. char course [10]; 22. }; 23. 24. { 25. struct personal person; 26. printf("input values\n");

27.

scanf("%s %s %d %s",&person.name,&person.birthday,&person.id,&pers on.course); 28. printf("%s %s %d %s\n",person.name,person.birthday,person.id,person .course); 29. fprintf(f1,"%s %s %d %s\n",person.name,person.birthday,person.id,person .course); 30. } 31. int n, m, i, j,t,s,roll_number, marks, total; 32. float average; 33. printf("enter number of students and subjects\n"); 34. fprintf(f1,"enter number of students and subjects"); 35. scanf("%d %d",&n,&m); 36. for(i=1;i<=10;i++); 37. { 38. printf("Enter roll_number"); 39. fprintf(f1,"Enter roll_number"); 40. scanf("%d",&roll_number); 41. total=0; 42. printf("\n Enter marks of %d subjects for roll No.%d \n",m,roll_number); 43. fprintf(f1,"\n Enter marks of %d subjects for roll No.%d \n",m,roll_number); 44. 45. for(j=1;j<=4;j++) 46. { 47. scanf ("%d",&marks); 48. total=total+marks; 49. } 50. average=total/m; 51. printf("Total marks=%4d",total); 52. fprintf(f1,"Total marks=%4d",total); 53. printf("average=%f\n", average); 54. 55. fprintf(f1,"average=%f\n", average); 56. 57. if (average>=70) 58. printf("Grade A\n\n"); 59. printf(f1,"Grade A\n\n"); 60. else if (average>=60) 61. printf("Grade B \n\n"); 62. fprintf(f1,"Grade B\n\n"); 63. else if (average>=50) 64. printf ("Grade C \n\n"); 65. fprintf(f1,"Grade C\n\n"); 66. else if (average>=45) 67. printf("Grade D\n\n"); 68. fprintf(f1,"Grade D\n\n"); 69. else if (average>=40) 70. printf("Grade E\n\n"); 71. fprintf(f1,"Grade E\n\n"); 72. else 73. printf("(***Fail***)");

74. 75. 76. 77. •

fprintf(f1,"(***Fail***)"); fclose(f1); } getch();

Related Documents

Mark Sheet
November 2019 33
12th Mark Sheet
May 2020 14
Unit Two Mark Sheet
October 2019 17
10th Mark Sheet
May 2020 11
Mark
June 2020 42