Exactly one of these code fragments calculates the sum of the integers from 1 through 9. Which one?
A
int n = 9;
int sum = 0;
while ( n > 1 )
{
sum += n;
}
B
int n = 9;
int sum = 0;
while ( n > 1 )
{
n--;
sum += n;
}
C
int n = 0;
int sum = 0;
while ( n < 9 )
{
sum += n;
n++;
}
D
int n = 9;
int sum = 0;
while ( n > 0 )
{
sum += n;
n--;
}
E
int n = 0;
int sum = 0;
while ( n <= 9 )
{
n++;
sum += n;
}
Exactly one of these code fragments calculates the sum of the integers from 1 through 9. Which one?
A
int n = 9;
int sum = 0;
while ( n > 1 )
{
sum += n;
}
B
int n = 9;
int sum = 0;
while ( n > 1 )
{
n--;
sum += n;
}
C
int n = 0;
int sum = 0;
while ( n < 9 )
{
sum += n;
n++;
}
D
int n = 9;
int sum = 0;
while ( n > 0 )
{
sum += n;
n--;
}
E
int n = 0;
int sum = 0;
while ( n <= 9 )
{
n++;
sum += n;
}
Exactly one of these code fragments calculates the sum of the integers from 1 through 9. Which one?
A
int n = 9;
int sum = 0;
while ( n > 1 )
{
sum += n;
}
B
int n = 9;
int sum = 0;
while ( n > 1 )
{
n--;
sum += n;
}
C
int n = 0;
int sum = 0;
while ( n < 9 )
{
sum += n;
n++;
}
D
int n = 9;
int sum = 0;
while ( n > 0 )
{
sum += n;
n--;
}
E
int n = 0;
int sum = 0;
while ( n <= 9 )
{
n++;
sum += n;
}
N equals 9
SUM equals 0
while N does NOT equal 0
add N to SUM
subtract 1 from N
Exactly one of these code fragments calculates the sum of the integers from 1 through 9. Which one?
A
int n = 9;
int sum = 0;
while ( n > 1 )
{
sum += n;
}
B
int n = 9;
int sum = 0;
while ( n > 1 )
{
n--;
sum += n;
}
C
int n = 0;
int sum = 0;
while ( n < 9 )
{
sum += n;
n++;
}
D
int n = 9;
int sum = 0;
while ( n > 0 )
{
sum += n;
n--;
}
E
int n = 0;
int sum = 0;
while ( n <= 9 )
{
n++;
sum += n;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.