# Answer to Question #25886 in C++ for riyam

Question #25886

write a program to read x and print sin x if x>0,square root x f x<0 and absolute x if x/2 is integer.

write c++ program to read two integer numbers,and read the operation to perform on these numbers

write c++ program to read 5 numbers and determine if the numbers sorted ascending or not

write c++ program to read two integer numbers,and read the operation to perform on these numbers

write c++ program to read 5 numbers and determine if the numbers sorted ascending or not

Expert's answer

//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.

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x;

cout << "Input the number: x = ";

cin >> x;

if(x > 0) cout << "Sin(x) = " << sin(x) << endl;

if(x < 0) cout <<"Sqrt(x) = "<< sqrt(-x) << "i" << endl;

if((x - (int)x == 0 )&&((int)x % 2 == 0)) cout<< "fabs(x) = " << fabs(x); &

getch();

return 0;

}

//write c++ program to read two integer numbers,and read the operation to

//perform on these numbers

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x, y;

char operation;

cout << "Input two numbers: " << endl;

cout << "x = ";

cin >> x;

cout << "y = ";

cin >> y;

cout << "Select operation (+, -, /, *):& ";

cin >> operation;&

if(operation == '+') cout << "x + y = " << x + y;

if(operation == '-') cout << "x - y = " << x - y;

if(operation == '*') cout << "x * y = " << x * y;

if(operation == '/') cout << "x / y = " << x / y;

getch();

return 0;

}

//write c++ program to read 5 numbers and determine if the numbers sorted

//ascending or not

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x1, x2, x3, x4, x5;

cout << "Input five numbers: " << endl;

cin >> x1;

cin >> x2;

cin >> x3;

cin >> x4;

cin >> x5;

if((x1 < x2) && (x2 < x3) && (x3 < x4) && (x4 < x5)) cout << endl <<"The numbers are sorted! ";

else cout << endl << "The numbers are not sorted! ";

getch();

return 0;

}

//square root x if x < 0

//and absolute x if x/2 is integer.

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x;

cout << "Input the number: x = ";

cin >> x;

if(x > 0) cout << "Sin(x) = " << sin(x) << endl;

if(x < 0) cout <<"Sqrt(x) = "<< sqrt(-x) << "i" << endl;

if((x - (int)x == 0 )&&((int)x % 2 == 0)) cout<< "fabs(x) = " << fabs(x); &

getch();

return 0;

}

//write c++ program to read two integer numbers,and read the operation to

//perform on these numbers

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x, y;

char operation;

cout << "Input two numbers: " << endl;

cout << "x = ";

cin >> x;

cout << "y = ";

cin >> y;

cout << "Select operation (+, -, /, *):& ";

cin >> operation;&

if(operation == '+') cout << "x + y = " << x + y;

if(operation == '-') cout << "x - y = " << x - y;

if(operation == '*') cout << "x * y = " << x * y;

if(operation == '/') cout << "x / y = " << x / y;

getch();

return 0;

}

//write c++ program to read 5 numbers and determine if the numbers sorted

//ascending or not

#include <iostream>

using namespace std;

#include <conio.h>

#include <math.h>

int main()

{

double x1, x2, x3, x4, x5;

cout << "Input five numbers: " << endl;

cin >> x1;

cin >> x2;

cin >> x3;

cin >> x4;

cin >> x5;

if((x1 < x2) && (x2 < x3) && (x3 < x4) && (x4 < x5)) cout << endl <<"The numbers are sorted! ";

else cout << endl << "The numbers are not sorted! ";

getch();

return 0;

}

## Comments

## Leave a comment