README.md

December 5, 2022 · View on GitHub

Age Algorithm - GREAT for Beginners!

Description

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.

More Info

Submitted On
ByBrian Griffin
LevelBeginner
User Rating4.0 (24 globes from 6 users)
CompatibilityC, C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
CategoryAlgorithms
WorldC / C++
Archive File

Source Code


/*************************************
* Age Calculation Algorithm *
* By: Brian Griffin *
*************************************/
#include
    //NOTE: the above line is supposed to say iostream.h inside <>'s following the include. It was interpreted as HTML so it disappeared.

void main(){
     int age, newYear, currentYear, newAge, next;

     cout << "Age Calculation Algorithm" << endl;
     cout << "By: Brian Griffin" << endl;
     cout << "--------------------------" << endl;
     cout << "Age: ";
    cin >> age;
     cout << "Current Year: ";
     cin >> currentYear;
     cout << "Year to find age in: ";
     cin >> newYear;
     cout << "--------------------------" << endl;

    newAge = (newYear - currentYear) + age;
    cout << "You will be " << newAge << " in the year " << newYear << "." << endl;
     cin >> next;
}