Add to Favorites    Make Home Page 1663 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » Program to find day when a date is given

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Program to find day when a date is given
Author P.Karthikeyan
Author Email p4karthikeyan [at] yahoo.com
Description This would calculate the day when date is given.
Category C » Beginners / Lab Assignments
Hits 382604
Code Select and Copy the Code
#include<stdio.h> main(){ int d,m,y,i; int r=0,r1=0,r2=0,s=0; input: printf(" Enter the DATE MONTH and YEAR "); scanf("%d %d %d",&d,&m,&y); if(m==2){ if((d>28)&&(y%4!=0)){ printf(" Fool,Invalid date in February of non leap year.The maximum value is 28"); goto input; } if((d>29)&&(y%4==0)){ printf(" Fool,Invalid date in February of leap year.The maximum value is 29"); goto input; } } else if((m==1)||(m==3)||(m==5)||(m==7)||(m==8)||(m==10)||(m==12)){ if(d>31){ printf(" Fool,Invalid date in %d th month.The maximum value is 31",m); goto input; } } else if(((m==4)||(m==6)||(m==9)||(m==11))&&(d>30)){ printf(" Fool,Invalid date in the %d th month.The maximum value is 30",m); goto input; } else if((d>31)){ printf(" Enter valid date "); goto input; } if((d<1)||(m<1)){ printf(" Fool,Enter positive valid data "); goto input; } else { switch(m){ case 1: case 10: r1=d+2; break; case 2: case 3: case 11: r1=d+5; break; case 4: case 7: r1=d+1; break; case 9: case 12: r1=d; break; case 5: r1=d+3; break; case 6: r1=d+6; break; case 8: r1=d+4; break; default: { printf(" Don't U know that there is no month greater than 12.Enter valid month Once again enter the Date Month Year "); goto input; } } } if(y<2003){ for(i=2002;i>=y;i--){ if((i==y)&&(i%4==0)){ if(m>2) s=s+1; else if(m<=2) s=s+2; break; } else if(i%4==0){ if(i%100==0){ if(i%400==0) s=s+2; else s=s+1; } else s=s+2; } else s=s+1; } r2=7-s%7; } else if(y>2003){ for(i=2004;i<=y;i++){ if((i==y)&&(i%4==0)){ if(m>2) s=s+2; else if(m<=2) s=s+1; break; } else if(i%4==0){ if(i%100==0){ if(i%400==0) s=s+2; else s=s+1; } else s=s+2; } else s=s+1; } r2=s%7; } else r2=0; r=(r1+r2)%7; printf(" "); switch(r){ case 0: printf("The Day is SUNDAY"); break; case 1: printf("The Day is MONDAY"); break; case 2: printf("The Day is TUESDAY"); break; case 3: printf("The Day is WEDNESDAY"); break; case 4: printf("The Day is THURSDAY"); break; case 5: printf("The Day is FRIDAY"); break; case 6: printf("The Day is SATURDAY"); break; } printf(" Thanks for using my program "); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=706


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review