First Upload
This commit is contained in:
46
3/ex3.c
Normal file
46
3/ex3.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define TEN_THOUSAND 10000
|
||||
#define ONE_HUNDRED 100
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Exercise 3
|
||||
// ----------
|
||||
//
|
||||
// General : The program print the date as a sentence.
|
||||
//
|
||||
// Input : 1 number.
|
||||
//
|
||||
// Process : The program take the year, month and day from the input and put in
|
||||
// a sentence.
|
||||
//
|
||||
// Output : A sentence.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Programmer : Cohen Idan
|
||||
// Student No : None
|
||||
// Date : 19.09.2019
|
||||
//---------------------------------------------------------------------------------------
|
||||
void main(void)
|
||||
{
|
||||
int date,
|
||||
temp_date;
|
||||
short day,
|
||||
month,
|
||||
year;
|
||||
|
||||
printf("Enter date: ");
|
||||
scanf("%d", &date);
|
||||
|
||||
temp_date = date;
|
||||
|
||||
year = temp_date - (temp_date / TEN_THOUSAND) * TEN_THOUSAND;
|
||||
temp_date /= TEN_THOUSAND;
|
||||
|
||||
month = temp_date - (temp_date / ONE_HUNDRED) * ONE_HUNDRED;
|
||||
temp_date /= ONE_HUNDRED;
|
||||
|
||||
day = temp_date;
|
||||
|
||||
printf("The year is %hd, the month is %hd, and the day is %hd\n", year, month, day);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user