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
What is action and transformation in spark?
What is a protocol in c?
What is the process of writing the null pointer?
What is extern variable in c with example?
How do we make a global variable accessible across files? Explain the extern keyword?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What are qualifiers?
What is sizeof return in c?
Explain what are preprocessor directives?
Explain what are run-time errors?
What are the __date__ and __time__ preprocessor commands?
What is a void pointer in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is the use of the function in c?
Can you please explain the difference between strcpy() and memcpy() function?