C++ Online Compiler
Example: C++ program to convert days into years, weeks and days
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to convert days into years, weeks and days #include <iostream> using namespace std; int main() { int d, y, w; // d = days // y = years // w = weeks cout << "Enter the days::\n"; cin >> d; /* Conversion of days in to years, weeks and days */ y = (d / 365); w = (d % 365) / 7; d = d - ((y * 365) + (w)); // Output cout << "\n" << y << " Year, " << w << " Weeks, and " << d << " Days\n"; return 0; }
464
Output
Clear
ADVERTISEMENTS