Advertisement
EBobkunov

struct_contains_info_about_students

Mar 10th, 2023
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. struct exam_day{
  4.     int day;
  5.     char month[20];
  6.     int year;
  7. };
  8.  
  9. struct student{
  10.     char name[50];
  11.     char surname[50];
  12.     int groupNumber;
  13.     struct exam_day E;
  14. };
  15.  
  16. int main() {
  17.  
  18.     struct student S;
  19.  
  20.     printf("Enter name of a student: ");
  21.     scanf("%s", S.name);
  22.     printf("Enter surname of a student: ");
  23.     scanf("%s", S.surname);
  24.     printf("Enter group number of a student: ");
  25.     scanf("%d", &S.groupNumber);
  26.  
  27.     printf("Enter day of the exam: ");
  28.     scanf("%d", &S.E.day);
  29.     printf("Enter month of the exam: ");
  30.     scanf("%s", S.E.month);
  31.     printf("Enter year of the exam: ");
  32.     scanf("%d", &S.E.year);
  33.  
  34.     printf("Information about student: %s %s, group number: %d \n The exam date is: %d, %s, %d.", S.name, S.surname, S.groupNumber, S.E.day, S.E.month, S.E.year);
  35.     return 0;
  36. }
  37.  
Tags: struct
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement