how to write in C++?

Answer:
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
using namespace::std;
int main()
{
int a,b; double m,x;
cout<<"Enter the value of x";
cin>>x;
if(x==1)
{
cout<<"Square root=="<<1;
}
else if(x>1)
{
a=1;
b=x;
}
else if(x<1)
{
a=x;
b=1;
}
do
{
m=(a+b)/2;
if(pow(m,2)==x)
{
exit(0);
}
else if(pow(m,2)>x)
{
b=x;
}
else if(pow(m,2)<x)
{
a=x;
}
}while((b-a)>0.000001*a);
cout<<"The mid point of a and b is square root of x=="<<m;
}
Explanation:
The program is the method to find the square root of the number. And the algorithm is just the replica of what has been shown in the image,