Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main() {
long double x;
cout << "x este: ";
cin >> x;
if (x < 0.0) {
cout << "x < 0 -- adevarat" << endl;
} else {
cout << "x < 0 -- fals" << endl;
}
cout << "sin pi*x = " << sin(x * 3.1415926) << endl;
if ((0.0 <= x) && (x <= 5.0)) {
cout << "0 <= x >= 5 -- adevarat" << endl;
} else {
cout << "0 <= x <= 5 -- fals" << endl;
}
cout << "x^3 = " << x * x * x << endl;
if (x >= 5.0) {
cout << "x >= 5 -- adevarat" << endl;
} else {
cout << "x >= 5 -- fals" << endl;
}
}
Explicație:
PROGRAM C++
#include <iostream>
#include <math.h>
using namespace std;
int main() {
double x;
cin >> x;
cout << (x <= 0 ? x + log(x) : (x <= 5 ? sin(3.14159265358979323846 * x) : pow(x,3)));
}
Nota :
Pentru x<0 logaritmul nu e definit.
Ai demonstratie in imagine ca programul functioneaza