Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct Attendance { // global structure
  6. char studentName[40];
  7. char programmeCode[4];
  8. int yearOfStudy;
  9. char groupCode;
  10. int groupNo;
  11. int daysAbsent;
  12. char actionTaken;
  13. };
  14. void main(){
  15. struct Attendance att;
  16. printf("Enter student name:");
  17. gets(att.studentName);
  18. printf("Enter programme code:");
  19. rewind(stdin);
  20. gets(att.programmeCode);
  21. printf("Enter year of study:");
  22. rewind(stdin);
  23. scanf("%d", &att.yearOfStudy);
  24. printf("Enter group code:");
  25. rewind(stdin);
  26. scanf("%c", &att.groupCode);
  27. printf("Enter group number:");
  28. rewind(stdin);
  29. scanf("%d", &att.groupNo);
  30. printf("Enter days of absent:");
  31. rewind(stdin);
  32. scanf("%d", &att.daysAbsent);
  33.  
  34. if(att.daysAbsent == 1 || att.daysAbsent == 2){
  35. strcpy(att.actionTaken, "warning to student");
  36. }else if(att.daysAbsent == 3 || att.daysAbsent == 4){
  37. strcpy(att.actionTaken, "inform parents");
  38. }else if(att.daysAbsent >= 5){
  39. strcpy(att.actionTaken, "bar from exam");
  40. }
  41. printf("Name Programme Group Days Absent Action\n");
  42. printf("-----------------------------------------------\n");
  43. printf("%s %s%d %c%d %d %s",att.studentName,att.programmeCode,att.yearOfStudy,att.groupCode,att.groupNo,att.daysAbsent,att.actionTaken);
  44.  
  45. system("pause");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement