Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include <iostream>

#include <cmath>

using namespace std;

double func(double);

int main() {
cout << "y = lntgx" << endl;

while(true) {
cout << endl << "enter x which satisfies the condition : nPI < x < nPI + PI /
2, n - int" << endl;
double x;
cin >> x;

try {
double z = func(x);
cout << z << endl;
}
catch (const char* err) {
cout << err << endl;
}
}

return 0;
}

double func(double x) {
double t = x;
int n = -1;

while(t >= 0) {
t -= M_PI;
n++;
}

if ((x <= n * M_PI || x >= M_PI * n + M_PI / 2.))


throw "ln argument cant be <= 0";
return log(tan(x));
}

You might also like