c++ - How to calculate the age of a person? -


for example, need calculate time past since 1996-11-03 (yy/mm/dd) until now. need in mc visual c++ in windows form app. user enter year, month, day in 3 different texbox'es. ideas?

may you....

 #include<iostream>     using namespace std;      int main()     {         system("title how old you?");         system("color f3");         int yearnow,yearthen,monthnow,monththen,age1,age2;          cout<<"\t\t\tenter current year , month \n\t\t\t(eg. 1997, enter, 7, enter):\n ";         cin>>yearnow;         cin>>monthnow;         cout<<"enter birthyear , month: \n";         cin>>yearthen;         cin>>monththen;          if(monththen >12 || monththen<1)             return 1;          if(monththen > monthnow){              age1=yearnow-yearthen-1;              age2=(12-monththen) + monthnow;         }else{              age1=yearnow-yearthen;              age2=12-monththen;         }         cout<<"\n\n\t\t\tyou "<<age1<<" year , "<<age2<<" moth old";         system("pause>>void");     } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -