Created
December 5, 2018 18:14
-
-
Save jjlumagbas/78619416bffc225c51acdbc6b21df08e to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <cstdlib> | |
#include <string> | |
#include <cmath> | |
using namespace std; | |
double calc_square(double n) { | |
return n * n; | |
} | |
string greet_name(string name) { | |
return "hello " + name; | |
} | |
const double CM_PER_INCH = 2.54; | |
double inches_to_cm(double x) { | |
return x * CM_PER_INCH; | |
} | |
bool can_swim_now(int temp) { | |
if (temp < 80) { return false; } | |
else if ((80 <= temp) and (temp <= 94)) { return true; } | |
else if (temp >= 95) { return false; } | |
} | |
string chem(int x) { | |
if (x < 6) { return "acid";} | |
else if (7 == x) { return "neutral";} | |
else if (x >= 8) { return "base";} | |
} | |
int main() { | |
cout << boolalpha; | |
cout << can_swim_now(89) << endl; | |
cout << inches_to_cm(10) << endl; | |
cout << chem(12) << endl; | |
cout << greet_name("mic") << endl; | |
cout << calc_square(6) << endl; | |
cout << 1 + 1 << endl; | |
cout << "Hello" << endl; | |
cout << true << endl; | |
cout << (true or false) << endl; | |
cout << (1 + 5) << endl; | |
// int: 5 | |
// double: 3.14 | |
system("pause"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment