Last active
August 17, 2019 02:48
-
-
Save saiedabbas93/5ab33a6f14f8633dfc2ef0618047ad74 to your computer and use it in GitHub Desktop.
If you input the date, the code will tell what day it will be.
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<conio.h> | |
#include<stdio.h> | |
void main() | |
{ | |
int k,m,d,c,f,day,day1,i; | |
printf("day=\n"); | |
scanf("%d",&k); | |
printf("Type the following codes for the required month\nMarch-1\t\tApril-2\t\tMay-3\t\tJune-4\n"); | |
printf("July-5\t\tAUgust-6\tSeptember-7\tOctober-8\n"); | |
printf("November-9\tDecember-10\tJanuary-11\tFebraury-12\n"); | |
scanf("%d",&m); | |
printf("Last 2 digits of year=\n"); | |
scanf("%d",&d); | |
printf("first 2 digits of year=\n"); | |
scanf("%d",&c); | |
if(m==11 || m==12) | |
d=d-1; | |
f=k + ((13*m-1)/5) + d + (d/4) + (c/4) - (2*c); /*Zellers Rule*/ | |
day=f%7; | |
if(day<0) | |
{ | |
for(i=0;i<7;i++) | |
{ | |
day=day-i; | |
if (day%7==0) | |
{ | |
day=day-day1; | |
} | |
i++; | |
} | |
} | |
if(m==11 || m==12) | |
{ | |
m=m-10; | |
d=d+1; | |
} | |
else | |
{ | |
m=m+2; | |
} | |
if (day==0) | |
printf("\n%d/%d/%d%d is Sunday",k,m,c,d); | |
else if (day==1) | |
printf("\n%d/%d/%d%d is Monday",k,m,c,d); | |
else if (day==2) | |
printf("\n%d/%d/%d%d is Tuesday",k,m,c,d); | |
else if (day==3) | |
printf("\n%d/%d/%d%d is Wednesday",k,m,c,d); | |
else if (day==4) | |
printf("\n%d/%d/%d%d is Thursday",k,m,c,d); | |
else if (day==5) | |
printf("\n%d/%d/%d%d is Friday",k,m,c,d); | |
else if (day==6) | |
printf("\n%d/%d/%d%d is Saturday",k,m,c,d); | |
} |
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
day= | |
16 | |
Type the following codes for the required month | |
March-1 April-2 May-3 June-4 | |
July-5 AUgust-6 September-7 October-8 | |
November-9 December-10 January-11 Febraury-12 | |
6 | |
Last 2 digits of year= | |
19 | |
first 2 digits of year= | |
20 | |
16/8/2019 is Friday |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment