Skip to content

Planet-Source-Code/brian-griffin-age-algorithm-great-for-beginners__3-4134

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

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
By Brian Griffin
Level Beginner
User Rating 4.0 (24 globes from 6 users)
Compatibility C, C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Category Algorithms
World C / 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;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published