Answer to Question #310819 in C++ for Diya

Question #310819

Write a program in c++ to input your age in years.the program will convert the age in months days,hours, minutes and seconds and then print all these values on screen

1
Expert's answer
2022-03-15T13:00:03-0400
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int ageInYears, ageInDays, ageInMonths,ageInHours, ageInMinutes,ageInSeconds;
    cout<<"Enter your age in years: ";
    cin>>ageInYears;
    ageInMonths = ageInYears*12;
    cout<<"Your age in months: "<<ageInMonths<<endl;
    ageInDays = ageInYears*365;
    cout<<"Your age in days: "<<ageInDays<<endl;
	ageInHours = ageInDays*24;
	cout<<"Your age in hours: "<<ageInHours<<endl;
	ageInMinutes = ageInHours*60;
	cout<<"Your age in minutes: "<<ageInMinutes<<endl;
	ageInSeconds = ageInMinutes*60;
	cout<<"Your age in seconds: "<<ageInSeconds<<endl;


	cin>>ageInYears;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment