-3
main ()
{
    int a; // Dabartine data
    int b; // Gimimo data
    int c;
    printf("Iveskite dabartine data formatu yymmdd:");
    scanf("%d", &a);
    printf("Iveskite savo gimimo data formatu yymmdd:");
    scanf("%d", &b);
    c = a - b;
    printf("Jusu amzius yra %d metai", c);
    return 0;
}

Could someone tell me how to make that in the end the result would be only 2 digits? It is a code to calculate your age accordingly to current date and date of birth. The answer is in yymmdd format and I need to remove the mmdd part and leave only the year part, for example: it prints 180602, and I only need to leave 18(it is the age of person)

mjay99
  • 3
  • 2

1 Answers1

2

You could try c = (a - b)/10000; That will discard the last 4 digits without rounding up.

Chang Qian
  • 1,091
  • 8
  • 15