Write a program to input month number and display number of days in that month

In the given program, 1 is for January, 2 for February, 3 for March, 4 for April, 5 for May, 6 for June, 7 for July, 8 for August, 9 for September, 10 for October, 11 for November, 12 for December.

#include<stdio.h>
void main()
{
   int n;
   printf("Enter a number: ");
   scanf("%d",&n);

   if(i==1)
   printf("\n January and total number of days is 31");
   else if(i==2)
   printf("\n February and total number of days is 28 or 29");
   else if(i==3)
   printf("\nMarch and total number of days is 31");
   else if(i==4)
   printf("\nApril and total number of days is 30");
   else if(i==5)
   printf("\nMay and total no. of days is 31);
   else if(i==6)
   printf("\nJune and total no. of days is 30");
   else if(i==7)
   printf("\nJuly and total no. of days is 31");
   else if(i==8)
   printf("\nAugust and total no. of days is 31");
   else if(i==9)
   printf("\nSeptember and total no. of days is 30");
   else if(i==10)
   printf("\nOctober and total no. of days is 31");
   else if(i==11)
   printf("\nNovember and total no. of days is 30");
   else if(i==12)
   printf("\nDecember and total no. of days is 31");
   else
   printf("\nInvalid month number entered");
 }

Post a Comment

0 Comments