Created
January 27, 2017 00:33
-
-
Save Adals20/e068a4aa2ab73a6b01f0529fe6951ac8 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 <cmath> | |
using namespace std; | |
double square_root(double x){ | |
return pow(x, 1.0/2); | |
} | |
double square_cube(double x){ | |
return cbrt(x); | |
} | |
int main(){ | |
double raiz, r2, r3, x; | |
cout << "Ingrese un numero para calcular su raiz cuadrada y cubica: "; | |
cin >> x; | |
if (x<0) | |
{ | |
cout << "Raiz cuadrada imaginaria" << endl; | |
r3 = square_cube(x); | |
cout << "Raiz cubica: " << r3 << endl; | |
} | |
else | |
{ | |
r2 = square_root(x); | |
cout << "Raiz cuadrada: " << r2 << endl; | |
r3 = square_cube(x); | |
cout << "Raiz cubica: " << r3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment