Created
March 2, 2022 16:22
-
-
Save kopriths/4f4f89ddb5f9e4a8ee603e7a76f5ebe5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
int chday(int day,int month,int year); | |
int chmonth(int month); | |
int chyear(int year); | |
int leapYear(int y); | |
int day_of_year(int d,int m,int y); | |
int chday(int day,int month,int year) { | |
if(month==1 && month==3 && month==5 && month==7 && month==9 && month==11){ | |
while (day < 1 && day > 31) { | |
return printf("H timh gia thn hmera den einai swsth"); | |
scanf("%d", &day); | |
} | |
} | |
else{ return printf("H timh gia thn hmera einai swsth"); | |
} | |
if(month==2 && (year%400==0)||((year%4==0)&&(year%100!=0))) | |
{ | |
while (day < 1 && day > 29) | |
{ | |
return printf("H timh gia thn hmera den einai swsth"); | |
scanf("%d", &day); | |
} | |
} | |
else { | |
return printf("H timh gia thn hmera einai swsth"); | |
} | |
if(month==2){ | |
while (day < 1 && day > 28) { | |
return printf("H timh gia thn hmera den einai swsth"); | |
scanf("%d", &day); | |
} | |
} | |
else{ | |
return("H timh gia thn hmera einai swsth"); | |
} | |
while (day < 1 && day > 30) { | |
return printf("H timh gia thn hmera den einai swsth"); | |
scanf("%d", &day); | |
} | |
return("H timh gia thn hmera einai swsth"); | |
} | |
int chmonth(int month) { | |
while (month < 1 && month > 12) { | |
return printf("H timh gia ton mhna den einai swsth"); | |
scanf("%d", &month); | |
} | |
return printf("H timh gia thn hmera einai swsth"); | |
} | |
int chyear(int year) { | |
while(year < 0) { | |
return printf("H timh gia ton xrono den einai swsth"); | |
scanf("%d", &year); | |
} | |
return printf("h timh gia ton xrono einai swsth"); | |
} | |
int leapYear(int y)//ÏÍÏÌÁ ÓÕÍÁÑÔÇÓÇÓ | |
{ | |
if((y%400==0)||((y%4==0)&&(y%100!=0))) | |
//Ýíá äßóåêôï Ýôïò åéíáé áñôéá äéáéñåôáéï ìå ôï 400 | |
//åíá äéóôåêôï åôïò åéíáé áñôéá ðïëëáðëáóóéï ìå ôï 4 | |
//áëëá áí ï÷é äéáéñåôáéï äéáéñåôáéï ìå ôï 100 | |
return printf("To etos einai disekto"); | |
else//all other years are not leap year | |
return printf("To etos den einai disekto"); | |
} | |
int day_of_year(int d,int m,int y){ | |
int s,l; | |
s=m*d;//áõôïò åéíáé ï áõîïíôáò áñéèìïò | |
l=365-s;//áõôåò åéíáé ïé ìåñåò ðïõ õðïëõðïíôáé | |
return printf("O afksontas arithmou einai %d kai oi meres pou upolupontai einai %d",s,l); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
// declaring variables | |
int day, month, year; | |
// input for day | |
printf("Dwse mera tou xronou: "); | |
scanf("%d", &day); | |
// input for month | |
printf("Dwse mhna tou xronou: "); | |
scanf("%d", &month); | |
// input for year | |
printf("Dwse xrono: "); | |
scanf("%d", &year); | |
struct hmeromhnia{ | |
int day; | |
int month; | |
int year; | |
}; | |
chday(day,month,year); | |
chmonth(month); | |
chyear(year); | |
leapYear(year); | |
day_of_year(day,month,year); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment