Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A) Although C++ doesn\'t have a \"secant\" function, you should write one. Thus,

ID: 675531 • Letter: A

Question

A) Although C++ doesn't have a "secant" function, you should write one. Thus, write a "sec" function and test it with at least 3 angles using this prototype: double sec(double radian); B) Now overload the "secant" function using this prototype: double sec(int degree); You will need to change degrees into radians inside the function. C) Now add a default parameter to your "secant" function using this prototype: double sec(double angle, int degrees, bool flag_radian=true); Where the default angle measurement is radians, degrees is whatever, and the flag_radian parameter is missing or true. If you want the angle in degrees, then it has a valid value, angle is whatever, and flag_radian is false and degrees will need to be converted into radians inside the function.

Explanation / Answer

#include <iostream>
#include<cmath>
using namespace std;
double sec(double radian){
double secant=cos(radian);
secant=1/secant;
return secant;
}
double sec(int degree)
{
double secant=cos((double)degree * 3.14 / 180.0 );
secant=1/secant;
return secant;
}
double sec(double angle,int degree,bool flag_radian=true)
{
if(flag_radian){
double secant=cos(angle);
secant=1/secant;
return secant;
}else{
double secant=cos((double)degree * 3.14 / 180.0 );
secant=1/secant;
return secant;
}
}


int main () {
cout<<sec(0.33)<<endl;
cout<<sec(90)<<endl;
cout<<sec(0.33,90,false);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote