Practice programming question: structs

  1. What is the output from the following program?
    #include <cstdio>
    #include <cstring>
    
    const int Len = 80;
    struct Names {
       char given[Len];
       char family[Len];
    };
    
    void EditNames(Names &n);
    Names GiveNames();
    
    int main()
    {
       Names N = { "try", "this" };
       printf("%s,%s\n", N.given, N.family);
       strcpy(N.given, "me");
       strcpy(N.family, "too)";
       printf("%s,%s\n", N.given, N.family);
       EditNames(N);
       printf("%s,%s\n", N.given, N.family);
    }
    
    void EditNames(Names &n)
    {
      strcpy(n.given, "changed)";
      strcpy(n.family, "both");
    }
    

  2. Write the definition for an AssignmentMark struct with the following fields:

  3. Write the definition for a StudentMarks struct with the following fields:

  4. Write a function, PrintMark, that takes a StudentMarks struct as a parameter and prints the fields

  5. Write a function, PrintCourseMarks, that takes an array of StudentMarks structs as one parameter, and the number of students in the course as a second parameter, and calls PrintMark once on each student's data.