Saturday, August 20, 2011

Count number of days in the given month of the year.

//Program to count number of days in the given month of  the year.
#include<stdio.h>
#include<conio.h>
void main()
{
 int y,m;
 clrscr();
 printf("Program to count number of days in the given month of the year");
 printf("\n\nPlease enter the month and the year");
 scanf("%d%d",&m,&y);
 switch(m)
 {
 case 1:
 case 3:
 case 5:
 case 7:
 case 8:
 case 10:
 case 12:
  printf("\n\nThe number of days in the given month of the year is 31");
  break;
 case 4:
 case 6:
 case 9:
 case 11:
  printf("\n\nThe number of days in the given month of the year is 30");
  break;
 case 2:
  if(y/100==0)
  {
   if(y%400==0)
    {
      printf("\n\nThe number of days in the given month of the year is 29");
    }
    else
    {
      printf("\n\nThe number of days in the given month of the year is 28");
    }
  }
  else
  {
   if(y%4==0)
   {
      printf("\n\nThe number of days in the given month of the year is 29");
    }
    else
    {
      printf("\n\nThe number of days in the given month of the year is 28");
    }
  }
  break;
 default:
   printf("You have entered a wrong month plz be make sure you have entered coorect information");
   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