Advertisement
AedenCak3

C program that reads name,month, & total number of days from the beginning of the year to that

Dec 12th, 2021
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.82 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
  6.     int d[]={31,28,31,30,31,30,31,31,30,31,30,31};
  7.     int monno;
  8.    printf("Input Month No : ");
  9.    scanf("%d",&monno);
  10.    switch(monno)
  11.    {
  12.  case 1:
  13.         printf("Name of the month: January\n");
  14.         printf("Last day of January is:%d\n",days[0]);
  15.         printf("It is %d days of the year",d[0]);
  16.         break;
  17.  case 2:
  18.         printf("Name of the month: February\n");
  19.         printf("Last day of February is:%d\n",days[1]);
  20.         printf("It is %d days of the year",d[0]+d[1]);
  21.         break;
  22.  case 3:
  23.         printf("Name of the month: March\n");
  24.         printf("Last day of March is:%d\n",days[2]);
  25.         printf("It is %d days of the year",d[0]+d[1]+d[2]);
  26.         break;
  27.  case 4:
  28.         printf("Name of the month: April\n");
  29.         printf("Last day of April is:%d\n",days[3]);
  30.                 printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]);
  31.         break;
  32.  case 5:
  33.         printf("Name of the month: May\n");
  34.         printf("Last day of May is:%d\n",days[4]);
  35.                 printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]);
  36.         break;
  37.  case 6:
  38.         printf("Name of the month: June\n");
  39.         printf("Last day of June is:%d\n",days[5]);
  40.         printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]);
  41.         break;
  42.  case 7:
  43.         printf("Name of the month: July\n");
  44.         printf("Last day of July is:%d\n",days[6]);
  45.          printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]);
  46.         break;
  47.  case 8:
  48.         printf("Name of the month: August\n");
  49.         printf("Last day of August is:%d\n",days[7]);
  50.         printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]+d[7]);
  51.         break;
  52.  case 9:
  53.         printf("Name of the month: September\n");
  54.         printf("Last day of September is:%d\n",days[8]);
  55.          printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]+d[7]+d[8]);
  56.         break;
  57.  case 10:
  58.         printf("Name of the month: October\n");
  59.         printf("Last day of October is:%d\n",days[9]);
  60.          printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]+d[7]+d[8]+d[9]);
  61.         break;
  62.  case 11:
  63.         printf("Name of the month: November\n");
  64.         printf("Last day of November is:%d\n",days[10]);
  65.          printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]+d[7]+d[8]+d[9]+d[10]);
  66.         break;
  67.  case 12:
  68.         printf("Name of the month: December\n");
  69.         printf("Last day of December is:%d\n",days[11]);
  70.            printf("It is %d days of the year",d[0]+d[1]+d[2]+d[3]+d[4]+d[5]+d[6]+d[7]+d[8]+d[9]+d[10]+d[11]);
  71.         break;
  72.  default:
  73.         printf("invalid Month number. \nPlease try again ....\n");
  74.         break;
  75.  
  76.  
  77.     return 0;
  78. }
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement