Assume that readInt reads and returns one integer value
int x, sumNeg=0, sumPos=0;
x=readInt();
while ( x != 0)
{
if (x<0)
sumNeg += x;
if (x>0)
sumPos +=x;
}
if (sumNeg < -8)
S.O.P.ln("negative sum: " + sumNeg);
if (sumPos > 8)
S.O.P.ln("positive sum: " + sumPos);
which of the following inputs would cause every line of code to be executed at least once?
0
2 4 6 8
2 -2 4 -4 0
4 -4 6 -6 0
-2 -4 -6- -8 0
2007-08-14
02:58:41
·
2 answers
·
asked by
dingdong
1
in
Computers & Internet
➔ Programming & Design
how did you get your sumPos and sumNeg answers
2007-08-14
03:33:31 ·
update #1