Write a programme which find years, months & days according to your DOB? in C language

Let’s understand some concept.

By this codes you can find or calculate your age (years, months & days ). If you want to understand the concept then read carefully and then use. According to “permutations and combination”. In your date of birth & current date, even your

  1. DOB date is smaller than current date & DOB month is smaller than current month. (current date 20/04/2020 & DOB 15/03/1998)
  2. DOB date is larger than current date and DOB Month is smaller than current month. (DOB 25/03/1998 & current date 20/04/2020)
  3. DOB date is smaller than current date & DOB month is larger than current month.(DOB 15/06/1998 & current date 20/04/2020)
  4. DOB date is larger than current date & DOB month is larger than current month. (DOB 25/06/1998 & current date 20/04/2020)

So, there are four possibilitie in which your date of birth and current date depend. That condition occurs, are explain above with possible examples.

Some important symbols used in code.

  • () small bracket
  • && use for ‘and’ use for address
  • {} curly bracket
  • “” double code
  1. #include<studio.h>
  2. #include<conio.h>
  3. Void main()
  4. int a, b, c, d, e, f, g, h,I, j, k;
  5. clrscr();
  6. printf(“Enter your date of Birth in format of DD/MM/YYYY”);
  7. Scanf(“%d%d%d”, &a, &b, &c);
  8. printf(“Enter your current Date in format of DD/MM/YYYY”);
  9. Scanf(“%d%d%d”, &d, &e, &f);
  10. If(a<d&&b<e)
  11. {
  12. i=d-a;
  13. j=e-b;
  14. k=f-c;
  15. printf(“%d Years %d Months %d Days”, k, j, i);
  16. }
  17. else if(d<a&&b<e)
  18. {
  19. i=(d+30)-a;
  20. j=(e-1)-b;
  21. k=f-c;
  22. prinf(“%d Years %d Months %d Days”, k, j, i);
  23. }
  24. If(a<d&&e<b)
  25. {
  26. i=d-a;
  27. j=(e+12)-b;
  28. k=(f-1)-c;
  29. printf(“%d Years %d Months %d Days”);
  30. }
  31. else if(d<a&&e<b)
  32. {
  33. i=(d+30)-a;
  34. j=(e+23)-b;
  35. k=(f-1)-c;
  36. printf(“%d Years %d Months %d Days”, k, j, i);
  37. }
  38. getch();
  39. }

Input

Take any example : date of birth: 29/03/1998 current date:20/04/2020

Results or output

22Years 0month 21days

Three digit number arrange in smallest order

Three digit number arrange largest than before

Leave a comment

Design a site like this with WordPress.com
Get started