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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I manipulate individual bits?

611


Explain what standard functions are available to manipulate strings?

614


What is the size of structure pointer in c?

616


What is a null string in c?

593


What is a protocol in c?

561






What is the difference between malloc calloc and realloc in c?

654


If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.

1791


What is c programming structure?

623


How reliable are floating-point comparisons?

632


How to declare pointer variables?

688


program to convert a integer to string in c language'

1988


What is the use of c language in real life?

535


What is huge pointer in c?

589


What is fflush() function?

649


What does malloc () calloc () realloc () free () do?

563