Write your question here.
The following pseudocode computes the square root of positive numbers using newton’s method.
Convert it into a c++ program.
1. input number x
2. If x<=0
a. Print “please enter positive number >0”
b. End program
3. Guess = 0.0
4. newGuess=1.0
5. while newGuess is not equal to Guess
a. guess=newGuess;
b. newGuess=(x/Guess + Guess)/2;
6. print guess
#include <iostream>
using namespace std;
int main (){
double x;
cout<<"please enter positive number";
cin>>x;
if (x<=0)
cout<<"please enter positive number>0"<<endl;
cin>>x;
#include <iostream>
usingnamespace std;
int main (){
double x; // Declared, not defined. You don't know what it is equal to.
cout<<"please enter positive number";
cin>>x;
if (x<=0) // Isn't something missing here?
cout<<"please enter positive number>0"<<endl;
cin>>x;
double Guess = 0.0 ,newGuess=1.0;
if(newGuess!=Guess) { // This and
Guess==newGuess; // makes no sense.
else (x%Guess + Guess%2); // What's this?
cout<<Guess;
}
return 0; // Does this belong outside the closing bracket?