Advertisement
4_2005-2006 OLE/ COM/ DCOM/ Active-X #164526

Age Algorithm - GREAT for Beginners!

This is my first C++ algorithm as well as my first submission to PSCode. It is definitely great for beginners. It has basic I/O and practices doing math in C++. You enter your age, the current year, and a year in the future and it tells you how old you will be in that year.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<br>
/*************************************<br>
* Age Calculation Algorithm *<br>
* By: Brian Griffin  *<br>
*************************************/<br>
#include <iostream.h><br>
  &nbsp;&nbsp;//NOTE: the above line is supposed to say iostream.h inside <>'s following the include. It was interpreted as HTML so it disappeared.
<br><br>
void main(){<br>
     int age, newYear, currentYear, newAge, next;<br><br>
     cout << "Age Calculation Algorithm" << endl;<br>
     cout << "By: Brian Griffin" << endl;<br>
     cout << "--------------------------" << endl;<br>
     cout << "Age: ";<br>
     cin >> age;<br>
     cout << "Current Year: ";<br>
     cin >> currentYear;<br>
     cout << "Year to find age in: ";<br>
     cin >> newYear;<br>
     cout << "--------------------------" << endl;<br><br>
     newAge = (newYear - currentYear) + age;<br>
     cout << "You will be " << newAge << " in the year " << newYear << "." << endl;<br>
     cin >> next;<br>
}<br>
Original Comments (3)
Recovered from Wayback Machine