You are not logged in.

#1 2015-09-15 05:53:26

hasnain
Administrator
From: Chichawatni
Registered: 2014-10-13
Posts: 8,355
Website

Sum Value:

http://interviewquestionsanswers.org/quiz/C-Programming http://interviewquestionsanswers.org/qu … Structures

Directions:
Consider the following program fragment:
for(c=1, sum=0; c <= 10; c++)
{
   scanf("%d", &x);
   if( x < 0 ) continue;
   sum += x;
}

Question:
What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5

Option A):
15
Option B):
12
Option C):
131
Option D):
14

Correct Answer is Option A):
15


Failure is the first step towards seccess.

2015-09-15 05:53:26

Advertisement
Ads By Google

Re: Sum Value:



Board footer