Saturday, August 20, 2011

Program to print the date in the 19 th century

//Program to print the date in the 19 th century
#include<stdio.h>
#include<conio.h>
void main()
{
 int d,m,y;
 void check(int,int,int);
 char c;
 clrscr();
 printf("Program to print the date in the 19 th century");
 while(1)
 {
 printf("\n Enter the three numbers please make sure that\"First value is less than equal to 31\" and also \"the second is less than equal to 12\" and \"third value is less than equal to 99\": ");
 scanf("%d%d%d",&d,&m,&y);
 if(d<=31&&m<=12&&y<=99)
 {
  y=19*100+y;
  switch(d)
  {
  case 29:
   case 30:
   case 31:
   if(m==2)
   {
     if(y%4==0&&y!=1900)
     {
      if(d<=29)
      {
       printf("\nDate entered by you is :");
       printf("%dnd ");
       break;
      }
      else
      {
        printf("\nyou have entered wrong date please make sure that you are entering correct data");
        continue;
      }
     }
    else
     {
      if(d>28)
      {
        printf("\n you have entered wrong date please make sure that you are entering correct data");
        continue;
      }
     }
   }
   else
   {
    if(d==31)
    {
     printf("\nDate entered by you is :");
     printf("%dst ");
     break;
    }
    else
    {
     printf("\nDate entered by you is :");
    printf("%dth ");
    break;
    }
   }
   case 1:
   case 21:
 printf("\nDate entered by you is :");
    printf("%dst ");
    break;
   case 2:
   case 22:
 printf("\nDate entered by you is :");
    printf("%dnd ");
    break;
   case 3:
   case 23:
 printf("\nDate entered by you is :");
    printf("%drd ");
    break;

   default:
 printf("\nDate entered by you is :");
    printf("%dth ");
  }
  switch(m)
  {
   case 1:
    printf("Jan ");
    break;
   case 2:
    printf("Feb ");
    break;
   case 3:
    printf("March ");
    break;
   case 4:
    printf("April ");
    break;
   case 5:
    printf("May ");
    break;
   case 6:
    printf("June ");
    break;
   case 7:
    printf("July ");
    break;
   case 8:
    printf("Aug ");
    break;
   case 9:
    printf("Sep ");
    break;
   case 10:
    printf("Oct ");
    break;
   case 11:
    printf("Nov ");
    break;
   case 12:
    printf("Dec ");
    break;
  }
  printf("%d",y);
 }
 else
 {
  printf("\nPlease read the instructions carefully and enter the correct data");
  continue;
 }
 printf("\n wheather you want display more dates please press y for \"Yes\" or n for \"No\": ");

 c=getche();
 if(c=='y'||c=='Y')
  continue;
  else
  break;
}
 getch();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More