• Language

    C

  • Description

    The date June 10, 1960, is special because when it is written numerically, the month time the day equals the year:
    6/10/60 --> 6*10 = 60
    Design a program that asks the user to enter a month (in numeric form), a day, and a two-digit year in three separate inputs. The program should determine whether the month times the day equals the year. If so, it should print, "This date is magic!" Otherwise, it should print, "This date is not magic."

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int day, month, two_digit_year;
    printf ("Enter the value of day: ");
    scanf ("%d", &day);
    (void) getchar ();
    printf ("Enter the value of month: ");
    scanf ("%d", &month);
    (void) getchar ();
    printf ("Enter the value of two digit year: ");
    scanf ("%d", &two_digit_year);
    (void) getchar ();
    if(day*month==two_digit_year)
        printf ("This date is magic!\n");
    else
        printf ("This date is not magic.\n");
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}