45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#include <stdio.h>
|
|
|
|
#define TEN_THOUSAND 10000
|
|
#define ONE_HUNDRED 100
|
|
#define MONTHS 12
|
|
#define THREE 3
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 4
|
|
// ----------
|
|
//
|
|
// General : The program print the period by month in date.
|
|
//
|
|
// Input : 1 number.
|
|
//
|
|
// Process : The program take the month, and check which belongs to period.
|
|
//
|
|
// Output : A sentence.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 19.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
int date,
|
|
temp_date;
|
|
short month;
|
|
|
|
printf("Enter date: ");
|
|
scanf("%d", &date);
|
|
|
|
temp_date = date / TEN_THOUSAND;
|
|
month = temp_date - (temp_date / ONE_HUNDRED) * ONE_HUNDRED;
|
|
|
|
month %= MONTHS;
|
|
month /= THREE;
|
|
|
|
printf("If you got '0' this WINTER \n\
|
|
If you got '1' this SPRING \n\
|
|
If you got '2' this SUMMER \n\
|
|
If you got '3' this AUTUMN \n\
|
|
You got: %hd\n", month);
|
|
}
|