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

Home » C Home » Mathematics Home » Calender (for all years)

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

Search Projects & Source Codes:

Title Calender (for all years)
Author K.E.Joseph
Author Email kejoseph77 [at] yahoo.co.in
Description Calender (for all years)
Category C » Mathematics
Hits 393907
Code Select and Copy the Code
/* ?????????????????????????????????????????????????????????????????????????? ???? ? CALENDAR ?????????????????????????????????????????????????????????????????????????? ????*/ # include <stdio.h> # include <conio.h> # include <string.h> # include <process.h> static char *month[] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; static char *weekday[]={ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", }; main() { int mm, yy; int key; clrscr(); printf( " ???????????????????????????????????????????????????"); printf( " ? ?"); printf( " ? Calender ?"); printf( " ? ?"); printf( " ??????????????????????????????????????????????????? "); printf(" ****Press any key****"); getch(); clrscr(); printf(" ???????????????????????????????????????????????????"); printf(" ?Calender from 01-01-01 to infinity.... ?"); printf(" ?Enter In this format: MM YYYY ?"); printf(" ?Writen in C language.. ?"); printf(" ?Design by: K.E. Joseph ?"); printf(" ??????????????????????????????????????????????????? "); l1: printf(" Please Enter month & year :"); scanf("%d %d", &mm, &yy); if(mm < 1 || yy<1) { printf(" Enter Correct data.. "); goto l1; } while(1) { clrscr(); display_calendar(mm, yy); puts("For navigation, use the arrow keys."); puts("To enter another date, press the Insert key."); puts("For RESET press INSERT key"); puts("Press ESC to exit."); printf(" ???????????????????????????????????????????????????"); printf(" ? Design by :K.Ebenezer Joseph ?"); printf(" ??????????????????????????????????????????????????? "); key = getkey(); switch(key) { case 72://up arrow key yy++; break; case 80://down arrow key yy--; break; case 75://left arrow key if(mm==1) { yy--; mm=12; } else mm--; break; case 77://right arrow key mm++; if(mm>12) { yy++; mm%=12; } if(mm==0) mm=12; break; case 1://escape key exit(0); case 82://Insert key return main(); } } } display_calendar(int mm, int yy) { char i, days; char first_day; char lines=1; first_day=find_day(1, mm, yy); printf(" ???????????????????????????????????????????????????"); printf(" ? %s-%d ?", month[mm],yy); printf(" ??????????????????????????????????????????????????? "); for(i=0; i<7;i++) printf("%s ", weekday[i]); puts(""); for(i=0; i<first_day;i++) printf(" "); //Find total no. of days in the month if (mm!=2) switch(mm) { case 4: case 6: case 9: case 11: days=30; break; default: days=31; } else isleapyear(yy)?(days=29):(days=28); for(i=1;i<=days;i++) { printf("%d ", i); if((i+first_day)%7==0) { puts(""); lines++; } } puts(" "); switch(lines) { case 4: puts(""); case 5: puts(""); } } find_day(int dd, int mm, int yy) { int odddays, leapyear; leapyear=isleapyear(yy); odddays=odddayyear(yy)+odddaymonth(mm,leapyear)+odddayday(dd); odddays %= 7; return odddays; } /*Every 4th year is a leap year, however centuries are not leap years except those divisible by 400 for example: 1990 is NOT a leap year 2000 is a leap year 2004 is a leap year */ isleapyear(int yy) { if(yy%4==0 && (yy%100!=0 || yy%400==0)) return 1; else return 0; } //Calculates odd days upto first day of year odddayyear(int yy) { int odddays=0; yy-=1; if(yy>=400) yy%=400; if(yy>=100) { odddays=yy/100; odddays *= 5; yy%=100; } odddays += yy; odddays += yy/4; return odddays; } odddaymonth(int mm, char leapyear) { switch(mm) { case 1: return 0; case 2: return 3; case 3: case 11: return leapyear?4:3; case 4: case 7: return leapyear?0:6; case 5: return leapyear?2:1; case 6: return leapyear?5:4; case 8: return leapyear?3:2; case 9: case 12: return leapyear?6:5; case 10: return leapyear?1:0; } } odddayday(int dd) { return dd%7; } //Returns scan code of the key that has been hit #include "dos.h" getkey() { union REGS i, o; while (!kbhit()) ; i.h.ah=0; int86(22, &i, &o); return (o.h.ah); } /*******************H I N T S ********************* Every 4th year is a leap year, however centuries are not leap years except those divisible by 400 for example: 1990 is NOT a leap year 2000 is a leap year 2004 is a leap year for example: ------------- 1 ordinary year = 365 days = (52 weeks + 1 day) = 1 odd day that's why if this year 23th August is on Tuesday, it will be on Wednesday next year 1 leap year = 366 days = (52 weeks + 2 days) = 2 odd days 100 years = 76 ordinary years + 24 leap years = [(76*52) weeks+76 days] + [(24*52) weeks+48 days] = 5200 weeks + 124 days = 5217 weeks + 5 days = 5 odd days 200 years = 10 odd days = 3 odd days 300 years = 15 odd days = 1 odd days 400 years = 20 + 1 odd days = 0 days 800 years = 0 odd days Sunday is the 0th odd day, Monday the 1st odd day and so on*/

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=1167


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