26. 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;
}
27. What will be printed if the following code is executed?
void main()
{
int x=0;
for( ; ; )
{
if( x++ == 4 ) break;
continue;
}
printf("x=%d", x);
}
void main()
{
int x=0;
for( ; ; )
{
if( x++ == 4 ) break;
continue;
}
printf("x=%d", x);
}
28. Consider the following code:
void main()
{
int a[5] = {6,8,3,9,0}, i=0;
if(i != 0)
{
break;
printf("%d", a[i]);
}
else
printf("%d", a[i++]);
}
What is the output of the above program?
void main()
{
int a[5] = {6,8,3,9,0}, i=0;
if(i != 0)
{
break;
printf("%d", a[i]);
}
else
printf("%d", a[i++]);
}