Question #82889

a program that accepts date of birth in the order of day,month and year and then displays it in the format: dd/mm/yy separated by a forward slash

Expert's answer

#include <stdio.h>
int main(void) {
    // Defining variables for day, month and year
    unsigned int day, month, year;
    // Reading day
    do {
        printf("Input day of birth:");
        scanf("%u", &day);
    } while (day < 1 || day > 31);
    // Reading month
    do {
        printf("Input month of birth:");
        scanf("%u", &month);
    } while (month < 1 || month > 12);
    // Reading year
    printf("Input year of birth:");
    scanf("%u", &year);
    printf("Date of birth in dd/mm/yy format is : %02u/%02u/%02u\n", day, month, (year % 100));
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS