Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int number;
- cout << "Insert a natural number: ";
- cin >> number;
- float root = sqrt(number);
- if((ceil(root) - root) > (root - floor(root)))
- cout << floor(root) << endl;
- else if((ceil(root) - root) < (root - floor(root)))
- cout << ceil(root) << endl;
- else
- cout << ceil(root) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement