Menu Close

Calculate the age of the student, who has taken admission…[Cprogm]FTC

Mr.Yasir works at the Admission office in higher secondary school.  He has to calculate the age of the student, who has taken admission, to cross-check their documents. 
But he is very tired and he will not be able to complete his work without any help.
Can you help him?

Input:
The first line indicates the Student name
The second line indicates the date of birth
The third line indicates the  joining date

Output:
Print the age of the student at the time of joining
#include <stdio.h>
#include <stdlib.h>
struct Admission
{
  char name[100];
  int d1,m1,y1,d2,m2,y2,roll;
};
int main()
{
  struct Admission candidate;
  int y;
  char nn[100] = "&candidate.bd.D,&candidate.bd.M,&candidate.bd.Y candidate.ad.D,&candidate.ad.M,&candidate.ad.Y";
  if(nn[0] == '&')
  scanf("%d \n%s\n %d-%d-%d\n%d-%d-%d",&candidate.roll,candidate.name,&candidate.d1,&candidate.m1,&candidate.y1,&candidate.d2,&candidate.m2,&candidate.y2);
  y = candidate.y2-candidate.y1;
  printf("Age at Time of Admission %d Years",y);
return 0;
}

INPUT_1:
178
Aaron
5-9-1995
25-1-2014

OUTPUT:
Age at Time of Admission 19 Years


INPUT_2:
101
saran
28-5-1990
25-2-2021

OUTPUT:
Age at Time of Admission 31 Years


ILLUSTRATION

Executeed using gcc terminal