#include <stdio.h>

typedef struct {
  int d, m, y;
} Date;

typedef struct {
  char name[60];
  double averageScore;
  Date dob; // date of birth
} Student;

struct Class {
  Student stud[30];
  int numStud;
};

int isYounger(Student student1, Student student2);

void main ( ) {
  Student
    student1 = {"Attar Annaufal", 96.9, {25, 11, 2004}},
    student2 = {"Budi Rahardjo", 95.2, {23, 11, 2004}};

  int compared = isYounger(student1, student2);

  if (compared == 1)
    printf("Student 1 is older\n");
  else if (compared == 2)
    printf("Student 2 is older\n");
  else
    printf("The age of the two students are same\n");
}

int isYounger(Student student1, Student student2) {
  if (student1.dob.y < student2.dob.y)
    return 1;
  else if (student1.dob.y > student2.dob.y)
    return 2;

  if (student1.dob.m < student2.dob.m)
    return 1;
  else if (student1.dob.m > student2.dob.m)
    return 2;
    
  if (student1.dob.d < student2.dob.d)
    return 1;
  else if (student1.dob.d > student2.dob.d)
    return 2;

  return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: