/*Example to demonstrate functions. We're going to use the predefined functions * in the math library (cmath) and the standard library (cstdlib). * In order to use functions in a library, include the library */ #include #include #include using namespace std; /*user defined function. Root of a quadratic equation * (-b +/- sqrt(b^2 - 4ac)) /2a * If the user picks 'P', we print the "larger" root. Otherwise, we print the other root. */ double quadRoot( double a, double b, double c, char pick) { if(pick == 'P' || pick =='p') return (-b + sqrt ( b*b - 4*a*c) ) / (2*a); else return (-b - sqrt ( b*b - 4*a*c) ) / (2*a); //We can also store the result in a variable and return the variable } int main() { //find the square root of a number cout<<"Enter a number: "; double num; cin>>num; double ans = sqrt(num); cout<<"The square root is "<>x; cout<<"Enter the exponent: "; cin>>y; //functions can have multiple parameters cout<<"x^y is "<>a>>b>>c; //We're using the function we defined earlier cout<<"The root is "<