C Programming Tutorial

Advertisements

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



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

              int mm;
              clrscr();
              
              cout<<"\nEnter month b/w 1 to 12 : ";
              cin>>mm;

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

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

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

              else
                     cout<<"\nInvalid month.";

              getch();
       }
       
   Output : 

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




Advertisement