i want to make a calendor?

This is a discussion on i want to make a calendor? within the C++ Programming forums, part of the General Programming Boards category; i want to make a calender program which takes the input form user as date,month and year and displays the ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    28

    i want to make a calendor?

    i want to make a calender program which takes the input form user as date,month and year and displays the day of it.
    for example today

    date is:09 month is:01 year is:2009

    andy day must be firday.

    also cater the feburary month which comes after 4 years.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,623
    I want you to read the homework policy.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    28
    thx
    .

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    28

    re

    now can anybody make it generic for all years?
    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>
    #include<string.h>
    int main()
    {   // which date is user provided do minus 1 from it,for seeing acutal value
    int date=1-1,monthDays=31,year=2009,save=0;
    clrscr();
    char *dayNameJan[7]={"Thrusday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    char *dayNameFeb[7]={"Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday"};
    char *dayNameMar[7]={"Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday"};
    char *dayNameApr[7]={"Wednesday","Thrusday","Friday","Saturday","Sunday","Monday","Tuesday"};
    char *dayNameMay[7]={"Friday","Saturday","Sunday","Monday","Tuesday","Wednesday","Thrusday"};
    char *dayNameJun[7]={"Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday","Sunday"};
    char *dayNameJul[7]={"Wednesday","Thrusday","Friday","Saturday","Sunday","Monday","Tuesday"};
    char *dayNameAug[7]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday"};
    char *dayNameSep[7]={"Tuesday","Wednesday","Thrusday","Friday","Saturday","Sunday","Monday"};
    char *dayNameOct[7]={"Thrusday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    char *dayNameNov[7]={"Sunday","Monday","Tuesday","Wednesday","Thrusday","Friday","Saturday"};
    char *dayNameDec[7]={"Tuesday","Wednesday","Thrusday","Friday","Saturday","Sunday","Monday"};
    
    
    //char *monthName[12]={"Jan","Feb","Mar","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
    char *monthName2="";
    int noOfDays=0,choseMonth=0,forChoseMonth=0;
    
          printf("\n\n\n\t\tpress 1....To Chose Month:");
          scanf("%d",&choseMonth);
          if(choseMonth==1)
          {
          clrscr();
          printf("\n\n\n\t\tpress 1....To Chose January:\n");
          printf("\t\tpress 2....To Chose February:\n");
          printf("\t\tpress 3....To Chose March:\n");
          printf("\t\tpress 4....To Chose April:\n");
          printf("\t\tpress 5....To Chose May:\n");
          printf("\t\tpress 6....To Chose June:\n");
          printf("\t\tpress 7....To Chose July:\n");
          printf("\t\tpress 8....To Chose August:\n");
          printf("\t\tpress 9....To Chose September:\n");
          printf("\t\tpress 10....To Chose October:\n");
          printf("\t\tpress 11....To Chose November:\n");
          printf("\t\tpress 12....To Chose December:\n");
          scanf("%d",&forChoseMonth);
          switch(forChoseMonth)
          {
    	   case 1:
    	   monthName2="Jan";
    	   break;
    	   case 2:
    	   monthName2="Feb";
    	   break;
    	   case 3:
    	   monthName2="Mar";
    	   break;
    	   case 4:
    	   monthName2="Apr";
    	   break;
    	   case 5:
    	   monthName2="May";
    	   break;
    	   case 6:
    	   monthName2="Jun";
    	   break;
    	   case 7:
    	   monthName2="Jul";
    	   break;
    	   case 8:
    	   monthName2="Aug";
    	   break;
    	   case 9:
    	   monthName2="Sep";
    	   break;
    	   case 10:
    	   monthName2="Oct";
    	   break;
    	   case 11:
    	   monthName2="Nov";
    	   break;
    	   case 12:
    	   monthName2="Dec";
    	   break;
    
          }
    
          }
    
    
         if(strcmp(monthName2,"Jan")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Feb")==0)
         {
    		noOfDays=28;
         }
         else if(strcmp(monthName2,"Mar")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Apr")==0)
         {
    		noOfDays=30;
         }
         else if(strcmp(monthName2,"May")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Jun")==0)
         {
    		noOfDays=30;
         }
         else if(strcmp(monthName2,"Jul")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Aug")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Sep")==0)
         {
    		noOfDays=30;
         }
         else if(strcmp(monthName2,"Oct")==0)
         {
    		noOfDays=31;
         }
         else if(strcmp(monthName2,"Nov")==0)
         {
    		noOfDays=30;
         }
         else if(strcmp(monthName2,"Dec")==0)
         {
    		noOfDays=31;
         }
    for(int i=0,i2=0,mi=0;i<noOfDays;++i,++i2,++mi)
    {
    	if(strcmp(monthName2,"Jan")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameJan[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameJan[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Feb")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameFeb[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameFeb[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Mar")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameMar[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameMar[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Apr")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameApr[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameApr[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"May")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameMay[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameMay[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Jun")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameJun[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameJun[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Jul")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameJul[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameJul[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    
    	else if(strcmp(monthName2,"Aug")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameAug[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameAug[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Sep")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameSep[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameSep[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Oct")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameOct[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameOct[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Nov")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameNov[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameNov[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	else if(strcmp(monthName2,"Dec")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayNameDec[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayNameDec[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
          /*	  int keepIt=date;
    	else if(strcmp(monthName2,"Feb")==0)
    	{
    		if(date%7==date)
    		{
    		    save=date;
    		    printf("%s",dayName[save]);
    		    break;
    		}
    		else if(date%7==i2)
    		{
    		    save=i2;
    		    printf("%s",dayName[i2]);
    		    break;
    		}
    
    		if(i2==7)
    		i2=0;
    		if(mi==noOfDays)
    		  mi=0;
    
    	}
    	 */
    
    
    }
    free(dayNameJan);
    free(dayNameFeb);
    free(dayNameMar);
    free(dayNameMay);
    free(dayNameJun);
    free(dayNameJul);
    free(dayNameAug);
    free(dayNameSep);
    free(dayNameOct);
    free(dayNameNov);
    free(dayNameDec);
    getch();
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 08:51 PM
  2. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 12:43 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21