?
Consider the following program fragment:
Consider the following program fragment:
for(c=1, sum=0; c <= 10; c++)
{
scanf("%d", &x);
if( x < 0 ) continue;
sum += x;
}
What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5
for(c=1, sum=0; c <= 10; c++)
{
scanf("%d", &x);
if( x < 0 ) continue;
sum += x;
}
What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5
Answer & Solution
Correct Answer:
Option
E
It is summation of 1+2+3+4+5 as continue statement is going to be executed for every input of -1, -2, -3, -4, -5.
Join the Discussion
Login to post a comment or share your explanation.
Login