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
How can I manipulate individual bits?
Explain what standard functions are available to manipulate strings?
What is the size of structure pointer in c?
What is a null string in c?
What is a protocol in c?
What is the difference between malloc calloc and realloc in c?
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.
What is c programming structure?
How reliable are floating-point comparisons?
How to declare pointer variables?
program to convert a integer to string in c language'
What is the use of c language in real life?
What is huge pointer in c?
What is fflush() function?
What does malloc () calloc () realloc () free () do?