60 736
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #57985 in C++ for sadeq

Question #57985
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.
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions