C Programming Tutorial

Advertisements

Write program to display the total days in a month in C



       #include<stdio.h>
       #include<conio.h>
       void main()
       {

              int mm;
              clrscr();
              
              printf("\nEnter month b/w 1 to 12 : ");
              scanf("%d",&mm);

              if(mm==1||mm==3||mm==5||mm==7||mm==8||m==10||mm==12)
                     printf("\n31 Days");

              else if(mm==4 || mm==6  || mm==9  || mm==11)
                     printf("\n30 Days");

              else if(mm==2)
                     printf("\n28/29 Days");

              else
                     printf("\nInvalid month.");

              getch();
       }
       
   Output : 

              Enter month b/w 1 to 12 : 8
              31 Days




Advertisement