simple,program,which,calculates,week,given,da
Quick Search for: in language:   
simple,program,which,calculates,week,given,da
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 342,436 lines
 Jobs: 945 postings

 

You are in:

 
Login


Latest Code Ticker for C/ C++
Hanoi's Towers
By eddy neon on 3/18


A High-Quality Game
By Adam Lendi on 3/18


Encrypto
By Mayank Jain on 3/18


file.cpp
By Arijit Sarkar on 3/18


tower of honai
By Rehan Ahmed Khan on 3/18


tower of honai (non-recursive)
By Rehan Ahmed Khan on 3/18


Click here to see a screenshot of this code!non-recursive tower of honai
By Rehan Ahmed Khan on 3/18

(Screen Shot)

OpenFile Dialog (ASM)
By RaX on 3/18


Computing very long Fibonacci numbers
By Alex Vinokur on 3/18


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

Day of the week(2002)

Print
Email
 
VB icon
Submitted on: 2/17/2002 6:36:12 AM
By: manish soni 
Level: Beginner
User Rating: By 3 Users
Compatibility:C, C++ (general), Borland C++

Users have accessed this code 399 times.
 
 
     Its a simple program which calculates the day of the week for any given date & month of the year 2002.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :Day of the week(200
//     2)
//**************************************
//     
#include<stdio.h> 
#include<conio.h> 
#include<iostream.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Day of the week(2002)
// Description:Its a simple program whic
//     h calculates the day of the week for any
//     given date & month of the year 2002.
// By: manish soni
//
// Inputs:Name & date of the month for t
//     he year 2002.
//
// Returns:It returns the "day of the we
//     ek" for the given month & date of the ye
//     ar 2002.
//
// Assumes:The logic is explained clearl
//     y in the program.With it even u can find
//     out the day of the week for any year.
Its calculated using a "key number" for a month.This can be understood from the "comment statements" in the program.
So go & find out the "trick" & then you can impress all your friends by telling them the "day of the week" for any month & date of yhe year.
do not forget to rate my progarm.
//
// Side Effects:Nill.
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.3322/lngWId.3/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

/*
Name: Manish soni.
E-Mail: manish_99us@yahoo.com
Language: C++
Category: Miscellaneous.
Description: Its a simple program which calculates the day of the week for any given date & month of the year 2002.
*/
#include<stdio.h> //include files.
#include<conio.h> 
#include<iostream.h> 
void main() //main function definition.
    { 
    int opt,date,day;//variable declaration.
    char b; 
    cout<<"****A program to find out the day of the week for any date of the year 2002****\n\n"; 
    cout<<"1.January\n2.February\n3.March\n4.April\n5.May\n6.June\n7.july\n8.August\n9.September\n10.October\n11.November\n12.December\n"; 
    a: cout<<"\nEnter the value of the month:"; 
    cin>>opt; 
    cout<<"\nEnter the date of the month:"; 
    cin>>date; 
    /*Calculates the value of the variable 'day'.
    this will be the final result based on which the "day of the week" is calculated.
    day= ((month number + date of the month)%number of days in a week);
    month number is as follows:
    "6" if the 1st day of the month is "sunday".
    "7" if the 1st day of the month is "monday".
    "8" if the 1st day of the month is "tuesday".
    "9" if the 1st day of the month is "wednesday".
    "10" if the 1st day of the month is "thursday".
    "11" if the 1st day of the month is "friday".
    "12" if the 1st day of the month is "saturday".
    */
    switch(opt) 
        { 
        case 1: if(date<=31) 
            {day=(8+date)%7;} 
            else
            cout<<"\nFor u'r kind information january has only 31 days.\n"; 
            break; 
            case 2: if(date<=28) 
                {day=(11+date)%7;} 
                else 
                cout<<"\nFor u'r kind information february has only 28 days.\n"; 
                break; 
                case 3: if(date<=31) 
                    {day=(11+date)%7;} 
                    else 
                    cout<<"\nFor u'r kind information march has only 31 days.\n"; 
                    break; 
                    case 4: if(date<=30) 
                        {day=(7+date)%7;} 
                        else 
                        cout<<"\nFor u'r kind information april has only 30 days.\n"; 
                        break; 
                        case 5: if(date<=31) 
                            {day=(9+date)%7;} 
                            else 
                            cout<<"\nFor u'r kind information may has only 31 days.\n"; 
                            break; 
                            case 6: if(date<=30) 
                                {day=(12+date)%7;} 
                                else 
                                cout<<"\nFor u'r kind information june has only 30 days.\n"; 
                                break; 
                                case 7: if(date<=31) 
                                    {day=(7+date)%7;} 
                                    else 
                                    cout<<"\nFor u'r kind information july has only 31 days.\n"; 
                                    break; 
                                    case 8: if(date<=31) 
                                        {day=(10+date)%7;} 
                                        else 
                                        cout<<"\nFor u'r kind information august has only 31 days.\n"; 
                                        break;
                                        case 9: if(date<=30) 
                                            {day=(6+date)%7;} 
                                            else 
                                            cout<<"\nFor u'r kind information september has only 30 days.\n"; 
                                            break; 
                                            case 10: if(date<=31) 
                                                {day=(8+date)%7;} 
                                                else 
                                                cout<<"\nFor u'r kind information october has only 31 days.\n"; 
                                                break; 
                                                case 11: if(date<=30) 
                                                    {day=(11+date)%7;} 
                                                    else 
                                                    cout<<"\nFor u'r kind information november has only 30 days.\n"; 
                                                    break; 
                                                    case 12: if(date<=31) 
                                                        {day=(6+date)%7;} 
                                                        else 
                                                        cout<<"\nFor u'r kind information december has only 31 days.\n"; 
                                                        break; 
                                                    } 

/* The value of the variable 'day' calculated above is checked for the conditions: if (day==0) then the day of the week is "sunday". if (day==1) then the day of the week is "monday". if (day==2) then the day of the week is "tuesday". if (day==3) then the day of the week is "wednesday". if (day==4) then the day of the week is "thursday". if (day==5) then the day of the week is "friday". if (day==6) then the day of the week is "saturday". */ if(day==0) {cout<<"\nIts SUNDAY.\n";} if(day==1) {cout<<"\nIts MONDAY.\n";} if(day==2) {cout<<"\nIts TUESDAY.\n";} if(day==3) {cout<<"\nIts WEDNESDAY.\n";} if(day==4) {cout<<"\nIts THURSDAY.\n";} if(day==5) {cout<<"\nIts FRIDAY.\n";} if(day==6) {cout<<"\nIts SATURDAY.\n";} cout<<"\n****************************************************\n"; cout<<"\nWould u like to continue?[y/n]:"; cin>>b; if(b=='y'||b== 'Y') goto a; else getch(); getch(); }

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.