#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
unsigned long int birthmonth,birthyear,birthhour;
unsigned long int currentmonth,currentyear,currenthour;
unsigned long int agey,agem,aget,ages;
double agemils,agemics,agens,ageps,agefs;
char ans;
top:
cout<<"\n\n\t\t\t WELCOME TO AGE CALCULATOR\n\n";
cout<<"Enter Your Birth Year(Eg:1989):";
cin>>birthyear;
cout<<"\n\nEnter Your Birth Month(Eg:7):";
cin>>birthmonth;
cout<<"\n\nEnter your birth hour(eg:3):";
cin>>birthhour;
cout<<"\nEnter The Current Year(Eg:2010):";
cin>>currentyear;
cout<<"\nEnter The Current Month(Eg:7):";
cin>>currentmonth;
cout<<"\nEnter The Current Hour(Eg:6):";
cin>>currenthour;
agey=currentyear-birthyear;
if(currentmonth>birthmonth)
{
agem=((currentyear-birthyear)*12)+(curre…
}
else
{
agem=((currentyear-birthyear-1)*12)+(cur…
}
aget=agem*30*24;
ages=aget*60;
agemils=aget*60*1000;
agemics=agemils*1000;
agens=agemics*1000;
ageps=agens*1000;
agefs=ageps*1000;
cout<<"\n\nYour Age in years= "<<agey<<"Years;\n\nYour Age in months="<<agem<<"Months\n\nYour Age in Hours="<<aget<<"Hours\n\nYour Age in seconds="<<ages<<"seconds";
cout<<"\n\nYour Age in Milliseconds= "<<agemils<<"milliseconds;\n\nYour Age in Microseconds= "<<agemics<<"microseconds;\n\nYour Age in NanoSeconds= "<<agens<<"nanoseconds";
cout<<"\n\nYour Age in Picoseconds= "<<ageps<<"Picoseconds;\nYour Age in femtoseconds= "<<agefs<<"femtoseconds";
cout << "\n Do you want to Try Again? (Y/N)" <<
Question:
I am doing a c++ project to check age from years,months.....femtoseconds. The problem is i am not getting the output required. i am getting correct
results upto agemils(age in milli seconds) then i get something e+xxxxx(x= number) like that. so i tried cout.precision() statement. then i dont get e+(exponential form(i guess!!)
but still i am not getting correct results. for conversion of milli to micro,micro to nano,nano to pico,pico to femto i just need 3 zeroes extra at every successive outputs keeping numbers same. but i am getting different numbers . this is quite strange i changed all data types. please help me with this problem soon.
Point out my mistakes and give new ideas (if any)
I am beginner to c++ so please explain me in detail