C++
#include <iostream>
using namespace std;
int main() {
// Declare variables
int age_years, age_days, age_months;
// Get the age in years from the user
cout << "Enter your age in years: ";
cin >> age_years;
// Calculate the age in days
age_days = age_years * 365;
// Calculate the age in months
age_months = age_years * 12;
// Print the age in days and months
cout << "Your age in days is: " << age_days << endl;
cout << "Your age in months is: " << age_months << endl;
return 0;
}
To run this program, you can save it as a .cpp
file and compile it using a C++ compiler. For example, on Linux or macOS, you can use the following command to compile the program:
g++ -o program program.cpp
Once the program is compiled, you can run it by typing the following command:
./program
For example, if you enter 20 as the age in years, the program will print the following output:
Enter your age in years: 20
Your age in days is: 7300
Your age in months is: 240
I hope this helps! Let me know if you have any other questions.