Code:
#include <iostream> //everything is in std:: namespace
#include <cmath> // Needed for rand operations.???
int main ()
{
char quit='N';
double userInput, estimate, sqrt_answer, y,x,a; //unused-unneeded variables
while (toupper(quit) != 'Y')
{
cout <<"enter non zero number *****:"<<flush;
cin >> userInput;
If (userInput <=0) //C++ is case sensitive
{
cout <<"invalid. would you like to quit?(y/n):"<<flush;
cin>> quit;
} //but you still go on calculating the sqrt
x = a = userInput;
y= 0;
//sqrt
lasty= 0; //undeclared
for(i=0;i<=15;i++) //undeclared i
{
y=0.5*(x+a/x);
x=y;
if (y == lasty)
break;
lasty=y;
/*close the loop, print lasty (or y, whichever), ask if user wants to quit, close
loop and main, and hand it in*/
If you fix the many errors, handling negative input is your biggest problem. You really can't use break, because that would exit the main loop and quit, while the user may have replied they want to continue. So you might rather need the continue keyword. Or just put everything that follows into an else block.