Solved

Choose the Loop That Is Equivalent to This Loop

Question 10

Multiple Choice

Choose the loop that is equivalent to this loop.
Int n = 1;
Double x = 0;
Double s;
Do
{
S = 1.0 / (n * n) ;
X = x + s;
N++;
}
While (s > 0.01) ;


A) double x = 0;
Double s = 1;
For (int k = 1; s > 0.01; k++)
{
S = 1.0 / (k * k) ;
X = x + s;
}
B) double x = 0;
Double s = 1;
For (int k = 1; k < 100; k++)
{
S = 1.0 / (k * k) ;
X = x + s;
}
C) double x = 0;
Double s = 1;
Int k = 10;
While (s > 0.01)
{
S = 1.0 / (k * k) ;
X = x + s;
K++;
}
D) double x = 0;
Double s = 10;
Int k = 1;
While (s > 0.01)
{
S = 1.0 / (k * k) ;
X = x + s;
K++;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions