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

Explain the binary height balanced tree?

716


Do you know what are the properties of union in c?

577


What is the difference between mpi and openmp?

727


What is a global variable in c?

585


What standard functions are available to manipulate strings?

556






What type is sizeof?

578


What is time complexity c?

562


What is queue in c?

570


What does it mean when the linker says that _end is undefined?

625


What are linker error?

612


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1176


Write a program to reverse a given number in c?

592


What is the difference between arrays and pointers?

627


What is string function in c?

530


Is it possible to pass an entire structure to functions?

548