Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- float root_square (float number){
- return sqrt(number);
- }
- int main()
- {
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- float num{};
- while (true) {
- cout << "Введіть будь-яке число: ";
- cin >> num;
- if (cin.fail()) {
- cin.clear();
- cin.ignore(32767, '\n');
- cout << "Число було введено неправильно. Спробуйте ввести інше!" << endl;
- continue;
- }
- else {
- break;
- }
- }
- if (num < 0) {
- cout << "Неможливо видобути корінь з від'ємного числа!";
- return 0;
- }
- else {
- cout << "Корінь числа: " << root_square(num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement