Find the Number of Years

less than 1 minute read

The code has been modified slightly and now uploaded to the site.

Question

<— Return Home

27.cpp

#include <iostream>
using namespace std;

int main(){
    long minutes;
    int totalYears;
    double years;
    int days;
    const double minutes_per_year = 525600.0;

    std::cout << "Enter the number of minutes: \n";
    std::cin >> minutes;

    years = minutes / minutes_per_year;
    totalYears = (int)years;
    // std::cout << years << totalYears << "\n";
    years = years - totalYears;
    // std::cout << years << "\n";
    days = (int)(years * 365);
    // std::cout << days << "\n";

    std::cout << minutes << " minutes is approximately " << totalYears << " years and " << days << " days";
}

<— Return Home