Created
August 18, 2019 00:49
-
-
Save sr229/f9ff48870529da1f98857539545e2e9d to your computer and use it in GitHub Desktop.
CS-111 files
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
/** | |
* Copyright 2019 (c) Ralph Wilson Aguilar | |
* For CS-111 | |
* Do not copy or redistribute without permission. | |
*/ | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main () | |
{ | |
int exponent, result; | |
cout << "Choose the exponent for 2: "; | |
cin >> exponent; | |
// we use pow() from cmath to do the heavy lifting for us | |
// it basically multiplies 2 to itself to N times (exponent). | |
result = pow(2.0 , exponent); | |
cout << "2 to the power of " << exponent << " is " << result << endl; | |
} |
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
/** | |
* Copyright 2019 (c) Ralph Wilson Aguilar | |
* For CS-111 | |
* Do not copy or redistribute without permission. | |
*/ | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main () | |
{ | |
int exponent, result; | |
cout << "Enter the exponent for e: "; | |
cin >> exponent; | |
// I'm really sure this is natural log. If not, the instructor can make me do a 10 second squat | |
// According to Google, e^x (natural log) is equal to 1 so idk about that. | |
result = log(exponent); | |
cout << "The natural logarithm of " << exponent << " is " << result << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment