2016-02-20T08:33:20-05:00
Write a program to read X and print Sin X if X>0, square root X if X<0
and absolute X if X/2 is integer.
1
2016-02-24T00:01:01-0500
#include <iostream> using namespace std; void main() { double X, halfx = 0; cout << "Please enter X: "; cin >> X; // input some number if (X > 0) // print sin X if X>0 { cout << "sin(" << X << ") = " << sin(X) << endl; } if (X <= 0) // print square root X if X<0 { cout << "sqrt(" << X << ") = " << sqrt(abs(X)) << "i" << endl; } if ((X / 2) == int((X / 2))) // print absolute X if X/2 is integer { cout << "abs(" << X << ") = " << abs(X) << endl; } system("pause"); }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments