Please accept my apologies for the mess — the site is under construction.


about / contact

the site
the webmaster

full cv (pdf)



the Lorentz boost (coming soon)

age finder program (c++)
17:08 4/20/2011

While programs that can print text to the screen may have their uses, the introduction of the user-definable variable absolutely expands their usefulness. The following program demonstrates the "int" (for integer) variable. In addition to returning the value of the variable at any point in the code, the program can be used to perform math functions with the variables.

In the case of "Age Finder", after giving a bit of information to the end user about the nature of the program, it asks for two values, "cyear" and "byear". After some simple math and adjustment(s) for those pesky things called months, days, and birthdays, it returns what age you'll be when the year finishes. As you will see, at the end, there is a simple loop that ensures the program does not close down until the user decides to kill the process – just an unfortunate aspect of the command-line program.

The code for the program is given below:

using namespace std;
int main()
    int cyear=0; // current year
    int byear=0; // birth year
    int age=0;   // age of EU (EU = End User)
    cout << "Age Finder:" << endl << endl;
    cout << "A simple program demonstrating" << endl << 
            "variables and simple math" << endl << endl;
    cout << "What year were you born? ";
    cin >> byear;
    cout << "What year is it currently? ";
    cin >> cyear;
    cout << "By midnight, 1/1/" << cyear+1 << ", you will be " << 
            age << ".";
    cout << endl << endl << "To close this program, click the X in the" << 
            endl << "top right corner of the program window.";
    while(1==1) {
      // this little loop keeps the program from closing down 
      // ...ever  until you click the "X"
    return 0;

"Age Finder" here. (475502bytes | 464KB)

This program was virus-free at the time of upload; however, is provided as-is. If you have any qualms, download a complier and build it yourself.

This website is run and maintained by George Wong. This webpage was last modified 17:08 4/20/2011 est.
You opened this page on and its subsidiaries are copyright 2003-2014.