Write a C++ program to find the square root of a number using Babylonian method
- برمجة سي بلس بلس
- برمجة
- 2021-05-13
- MarwaMohammed
الأجوبة
#include <iostream>
using namespace std;
float square_Root(float num)
{
float x = num;
float y = 1;
float e = 0.000001;
while (x - y > e) {
x = (x + y) / 2;
y = num / x;
}
return x;
}
int main()
{
int n = 50;
cout << "Square root of " << n << " is " << square_Root(n);
n = 81;
cout << "\nSquare root of " << n << " is " << square_Root(n);
return 0;
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال