C++ Program to Convert Days Into Years Weeks and Days

Problem

Write a Program in C++ programming language to Convert Days Into Years Weeks and Days.

Solution

Here’s a sample code snippet showing how to Convert Days Into Years Weeks and Days in C++.

#include<iostream>

using namespace std;

int main()
{
    int y,d,w;

    cout<<"Enter No. of days: ";
    cin>>d;

    y=d/365;
    d=d%365;
    w=d/7;
    d=d%7;

    cout<<"\nNo. of Years: : "<<y;
    cout<<"\nNo. of Weeks :: "<<w;
    cout<<"\nNo. of Days :: "<<d<<"\n";

    return 0;
}

Output

C++ Program to Convert Days Into Years Weeks and Days