Skip to content

Commit

Permalink
moar tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozwiak committed Dec 18, 2015
1 parent 94c035c commit 7fe46c8
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions learnCPP/learncpp.com/Chapter3/operators.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <iostream>
#include <cmath>

using std::cout;
using std::cin;

int16_t isEven(int16_t x);

int main()
{
cout << "Please enter a #: ";
int32_t x{};
cin >> x;
cout << "Please enter the ^ you would like to use: ";
int32_t y{};
cin >> y;
cout << "Answer is: " << pow(x , y) << "\n";

int16_t a{7};
int16_t b{4};

cout << "int16_t / int16_t = " << a / b << "\n";
cout << "int16_t / double = " << a / static_cast<double>(b) << "\n";

cout << "Inser a # and we'll check if it's even or odd: ";
int16_t number{};
cin >> number;
isEven(number);

return 0;
}

int16_t isEven(int16_t x) {

if (x % 2 == 0) {
cout << "It's an even #!!" << "\n";
} else {
cout << "Nope, definitely not a even #" << "\n";
}

// (x % 2 == 0) ? cout << "It's an even #!!" << "\n" : cout << "Nope, definitely not a even #" << "\n";

return 0;
}

0 comments on commit 7fe46c8

Please sign in to comment.