-3

Write a program which accept days as integer and display total number of years,months and days in it? ex. If user input as 856 days the output should be 2 years 4 monthes 6 days.

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by np complete
0

Daniweb is not a homework service. Please provide some proof that you've attempted to write this program on your own.

0

No.
Instead, I'll give you this.

#include <iostream>

using namespace std;
#define KM_M  1000
#define M_CM  100
#define CM_MM 10

int main(){
    long long mm, cm, m, km;
    cout<<"Input number of kilometers:";
    cin>>km;
    cout<<"Input number of meters:";
    cin>>m;
    cout<<"Input number of centimeters:";
    cin>>cm;
    cout<<"Input number of millimeters:";
    cin>>mm;
    m+=km*KM_M;
    cm+=m*M_CM;
    mm+=cm*CM_MM;
    cout<<"Your total distance in millimeters is: "<<mm<<"mm.\n";
    return 0;
}
0

For a simple approach, first by dividing input by year, taking remainder and again do samething, except use months and days.
Now after you have coded them, post them.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.