Result of the following program is
main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a)0,5,9,13,17
b)5,9,13,17
c)12,17,22
d)16,21
e)syntax error

Answers were Sorted based on User's Feedback



Result of the following program is main() { in..

Answer / arvind

the answer is syntax error but if there was a : after default

the execution would be like:
for i=0 case 0 is executed and then since there is no break
statement all the cases including the default case are
executed and the 16 is printed,.then i is iterated using
i++, now i=17 ,it enters the switch statement and only
default case is executed and i=i+5=21 is printed

Is This Answer Correct ?    37 Yes 6 No

Result of the following program is main() { in..

Answer / vinod

int main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
{
case 0: i+=5;
case 1: i+=2;
case 5: i+=5;
default: i+=4; break;
}
printf("%d,",i);
}
}

For the above program the output would be 16 and 21

Is This Answer Correct ?    35 Yes 5 No

Result of the following program is main() { in..

Answer / jai

Answer is e), since opening and closing flower braces do
not match in numbers and default do not have colon
following it. Assuming switch(i) has an opening flower
brace and default has colon after it "switch(i) {, ...
default: i+= 4;"answer would be d).
All cases will be fall-through including default:

Is This Answer Correct ?    27 Yes 5 No

Result of the following program is main() { in..

Answer / priya

the answer is syntax error
main()// no return type there will be warning
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)// there no starting braces
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;//illegal default
statement should end with : i.e.,default:
break;}
printf("%d,",i);
}
}

Is This Answer Correct ?    8 Yes 3 No

Result of the following program is main() { in..

Answer / shweth

e)sysntax error

Bcoz braces are not put properly. If there is no sysntax
error, means braces r put properly means result would be d)
16,21

Is This Answer Correct ?    6 Yes 8 No

Result of the following program is main() { in..

Answer / mayank sharma

when the control will encounter break statement.it will move
outside the loop. which will not pass through printf();and
also braces are not properly put

Is This Answer Correct ?    1 Yes 3 No

Result of the following program is main() { in..

Answer / sankar

Answer is (e) Option : Syntax error

void main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5; // this is illegal
case 1:i+=2; // this is illegal
case 5:i+=5; // this is illegal
default i+=4; // Colon is missing
break;
}
printf("%d,",i);
}
} // This is extra braces

Is This Answer Correct ?    4 Yes 6 No

Result of the following program is main() { in..

Answer / deepa

syntax error every case statement requires a break statement

Is This Answer Correct ?    7 Yes 32 No

Post New Answer

More C Interview Questions

What is memcpy() function?

0 Answers  


how to find out the reverse number of a digit if it is input through the keyboard?

6 Answers  


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CISOC, CitiGroup, College School Exams Tests,


we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?

0 Answers  


What is the use of structure padding in c?

0 Answers  






What is file in c preprocessor?

0 Answers  


How to throw some light on the b tree?

0 Answers  


write a program in c language that uses function to locate and return the smallest and largest integers in an array,number and their position in the array. it should also find and return the range of the numbers , that is , the difference between the largest number and the smallest.

1 Answers  


What is the correct declaration of main?

0 Answers  


Explain what?s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?

1 Answers  


Why is #define used?

0 Answers  


5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.

0 Answers  


Categories