ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
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
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
syntax error every case statement requires a break statement
 
Is This Answer Correct ?    0 Yes 0 No
Deepa
 
  Re: 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
# 2
Answer is e), since opening and closing flower braces do 
not match in numbers and default do not have colon 
following it. Assuming switch(i) has an opening flower 
brace and default has colon after it "switch(i) {, ... 
default: i+= 4;"answer would be d).
All cases will be fall-through including default:
 
Is This Answer Correct ?    0 Yes 0 No
Jai
 
 
 
  Re: 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
# 3
e)sysntax error

Bcoz braces are not put properly. If there is no sysntax 
error, means braces r put properly means result would be d)
16,21
 
Is This Answer Correct ?    0 Yes 0 No
Shweth
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
a memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed: s="Etrance" l=strlen(s); what is the value of l ? a.20 b.8 c.9 d.21 TCS2
write an interactive program to generate the divisors of a given integer. TCS2
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes HCL10
hat is a pointer? Assurgent3
void main() { int i=5; printf("%d",i+++++i); } ME12
write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview Satyam2
Predict the output or error(s) for the following: 25. main() { printf("%p",main); } ME3
post new interiew question and aptitude test papers  1
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?  2
What is the output for the following program #include<stdio.h> main() { char a[5][5],flag; a[0][0]='A'; flag=((a==*a)&&(*a==a[0])); printf("%d\n",flag); } ADITI3
what is the use of getch() function in C program.. difference b/w getch() and getche()?? Wipro10
How to avoid structure padding in C? Tech-Mahindra3
main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? } NDS12
what are the various memory handling mechanisms in C ? HP2
How to add two numbers without using arithmetic operators? Sapient7
WAP to accept first name,middle name & last name of a student display its initials? NIIT1
What is an anonymous union and where to apply that ? HP1
What is encapsulation?  1
What is structure packing ? HP1
Who had beaten up hooligan "CHAKULI" in his early college days?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com