Create a program that will allow user to enter an integer number and display its square root and absolute value
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
cout << "Enter an integer: ";
cin >> n;
cout << "It\'s absolute value is " << abs(n) << endl;
if (n >= 0) {
cout << "It\'s square root is " << sqrt(n) << endl;
}
else {
cout << "It has no real square root" << endl;
}
return 0;
}
Comments