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 discover how many arguments a function was actually called with?
Why does the call char scanf work?
What is the meaning of && in c?
What are the different data types in C?
Can we assign integer value to char in c?
What are the types of pointers?
What are the main characteristics of c language describe the structure of ac program?
What is struct node in c?
Tell me what is the purpose of 'register' keyword in c language?
How do you list a file’s date and time?
What are the types of macro formats?
Explain what standard functions are available to manipulate strings?
how to execute a program using if else condition and the output should enter number and the number is odd only...
Explain bit masking in c?
formula to convert 2500mmh2o into m3/hr