Last active
December 13, 2023 23:15
-
-
Save mshafae/440681ee258659c96d40eb9eb60b14e5 to your computer and use it in GitHub Desktop.
Calculate your age using a constant current year.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gist https://gist.github.com/440681ee258659c96d40eb9eb60b14e5 | |
#include <iostream> | |
#include <string> | |
const int kThisYear{2022}; | |
int main(int argc, char const *argv[]) { | |
int your_birth_year{0}; | |
std::cout << "What year where you born? "; | |
std::cin >> your_birth_year; | |
int age{kThisYear - your_birth_year}; | |
std::cout << "You were born in " << your_birth_year | |
<< " which means that you are " << age << " years old.\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment