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
Should I learn data structures in c or python?
What is volatile variable how do you declare it?
What is s in c?
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
What is the benefit of using const for declaring constants?
Explain About fork()?
Explain what is dynamic data structure?
What is ambagious result in C? explain with an example.
What is c programing language?
What are the benefits of c language?
Explain what’s a signal? Explain what do I use signals for?
What are comments and how do you insert it in a C program?
How can I delete a file?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What are the different types of constants?