Browse Source

Add C++ to list

master
parent
commit
f3ae772050
Signed by: StormFireFox1 <matei@gardus.eu> GPG Key ID: F3D2B830AB9B94AA
2 changed files with 42 additions and 1 deletions
  1. 2
    1
      README.md
  2. 40
    0
      isEven.cpp

+ 2
- 1
README.md View File

@@ -5,4 +5,5 @@ I like getting a feel for whatever language I think would work best for a specif
This is a Git repository of elementary algorithm programs for every language I know so that I can see which one I like best.

## Programming Languages List
- C
- C
- C++

+ 40
- 0
isEven.cpp View File

@@ -0,0 +1,40 @@
#include <iostream>

/* "Even number check"
*
* C++ was the second programming language I ever learned, and I did because I wanted to study Object-Oriented Programming.
* God, I was stupid back then.
*
* Frankly, I'll admit: I picked this language back then to study next because I was too much of a wuss to try any other one.
* I thought it would be similar to C and not be a completely different language to spook me out. I was not wrong, but not
* right either.
*
* Templates are hell to try to write, and this program will completely avoid them. But the classes are a nice touch to C that
* I really like. Plus, C++ was actually the language I used for schoolwork, not C. So I guess C++ brings me the bad memories.
*
* This algorithm just checks for an even number from standard input. Simple enough.
*/

bool isEven(long long int x)
{
if (x % 2 == 0)
{
return true;
} else {
return false;
}
}

int main()
{
long long int x;
std::cout << "Gimme an even number: ";
std::cin >> x;
if (isEven(x))
{
std::cout << "That's an even number! Well done!";
} else {
std::cout << "You donut, that isn't even. What are you doing with your life?";
}
return 0;
}

Loading…
Cancel
Save