I am not sure that this code is going to calculate the square root:
1 2 3 4 5 6 7 8
|
cin >> start1;
start2 = start1;
long halfstart;
halfstart = start1/2;
for (long x=halfstart;x--;start1=x*x)
{
halfstart--;
}
|
It's executed while
x--
is true meaning for all values
x>0
since x could not be negative (no check for that but we will pass it for now).
For example if user enters 4 so
start1 = 4
so is
start2
.
halfstart = 2
.
x and halfstart are following the same decremental step so they end up always 0 both.
This examples loops give:
x halfstart
loop 1: 2 2
loop 2: 1 1
loop 3: 0 0
For each step you increment
start1=x*x
but you n ever use it.
You are not using start2 at all (I think you don't want this).
I think you should study a bit the way
for
loops are intended to work.
You also use
goto
! Really bad choice. DON"T use them at whatevver cost. Sometimes they seem like the easiest way but don't even get to the point of validating their use. There is always an alternative for this. Find it out and use that instead.