Sunday, 15 June 2014

C++ program to convert days into months and days



Here is a C++ program to convert days into months and days


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int days,year,month=0;
    int months[]={31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31};
    cout<<"Enter the value in days ";
    cin>>days;
    for(int i=0;days>=months[i];i++)
    {
        days-=months[i];
        month++;
        if(i>=11)
            i=1;
    }
    cout<<month<<" month "<<days<<" days";
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment