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
Explain the binary height balanced tree?
Do you know what are the properties of union in c?
What is the difference between mpi and openmp?
What is a global variable in c?
What standard functions are available to manipulate strings?
What type is sizeof?
What is time complexity c?
What is queue in c?
What does it mean when the linker says that _end is undefined?
What are linker error?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
Write a program to reverse a given number in c?
What is the difference between arrays and pointers?
What is string function in c?
Is it possible to pass an entire structure to functions?