Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4.  
  5. #define SIZE 5
  6.  
  7. typedef char string10[11];
  8.  
  9. struct bdaystruct{
  10. int year;
  11. int month;
  12. int day;
  13. };
  14.  
  15. typedef struct {
  16. string10 name;
  17. int id;
  18. float gpa;
  19. struct bdaystruct bday;
  20. }studentBlock;
  21.  
  22. void inputinfo(studentBlock* student, studentBlock* students){
  23.  
  24.  
  25.  
  26.  
  27.  
  28. int i;
  29. for (i = 0 ; i < SIZE ; i++)
  30. {
  31. student->bday.day=i;
  32. student->bday.month=i;
  33. student->bday.year=i;
  34.  
  35. student->gpa=i;
  36. student->id=i;
  37.  
  38. students[i] = *student;
  39. }
  40.  
  41. }
  42.  
  43. void displayinfo(studentBlock* students){
  44.  
  45.  
  46.  
  47. int i;
  48. for(i = 0 ; i < SIZE ; i++){
  49. printf("Id no. [%d]: %d\n", i + 1, students[i].id);
  50. printf("GPA [%d]: %.2lf\n", i + 1, students[i].gpa);
  51. printf("Birthday [%d], %d / %d / %d\n", i + 1, students[i].bday.month,students[i].bday.day,students[i].bday.year);
  52. printf("\n");
  53. }
  54. //printf("Name [%d]: %s\n",1 , student[0]->name);
  55.  
  56.  
  57. }
  58.  
  59. int main(){
  60.  
  61.  
  62. studentBlock student, students[SIZE];
  63.  
  64.  
  65.  
  66. inputinfo(&student, students);
  67. displayinfo(students);
  68.  
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement