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
#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;
}
Comments
Leave a comment