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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -