Vous êtes sur la page 1sur 4

C INTERVIEW QUESTIONS

1. Is a default case necessary in a switch statement? 2. When is a switch statement better than multiple if statements? 3. Can the last case of a switch statement skip including the break? 4. When is the comma operator used? 5. o! can you tell !hether a loop ended prematurely? ". What is an lvalue # rvalue? $. Can an array be an lvalue? %. &o array subscripts al!ays start !ith 'ero? (. Can the sizeof operator be used to tell the si'e of an array passed to a function? 1). Is it better to use a pointer to na*igate an array of *alues+ or is it better to use a subscripted array name? 11. What is the difference bet!een array_name and &array_name? 12. Where in memory are our *ariables stored? ,auto+ static,data segment-+dma13. &o *ariables need to be initiali'ed? 14. When should a type cast be used? 15. When should I declare a function? 1". Why should I prototype a function? 1$. o! many parameters should a function ha*e? 1%. o! can you pass an array to a function by *alue? 1(. Is using exit() the same as using return? 20. What are the different storage classes in C? 21. What is a null pointer? 22. &ifference bet!een const char. p and char const. p , In const char. p+ the character pointed by /p0 is constant+ so u cant change the *alue of character pointed by p but u can make /p0 refer to some other location. In char const. p+ the ptr /p0 is constant not the character referenced by it+ so u cant make /p0 to reference to any other location but u can change the *alue of the char pointed by /p0.-

C-Aptitude test-3
&epartment of C12+ 34C College of 2ngineering 5age 1

1. 6he follo!ing program fragment int 7 8 4+ y 8 7+ i9 for ,i 8 19 i : 49 ;; i7 ; 8 79 outputs an integer that is same as ,<- % . y ,3- y . , 1 ; 2 ; 3 ; 4,C- y . 4

,&- y . y b.

2. If storage class is missing in the array definition+ by default it !ill be taken to be ,<- automatic ,3- e7ternal ,C- static ,&- either automatic or e7ternal depending on the place of occurrence 3. =or!ard declaration is absolutely necessary ,<- if a function returns a non>integer ?uantity ,3- if the function call precedes its definition ,C- if the function call precedes its definition and the function returns a non integer ?uantity ,&- none of these 4. puts ,arg* @)A- 9 ,<-prints the name of the source code file ,3- prints arg* ,C- prints the number of command line arguments ,&-prints the name of the e7ecutable code file 5. What !ill be output if you compile and e7ecute the follo!ing C code? Binclude:stdio.hC main,D printf,EFdE+si'eof,5.2--9 G ,<- 2 ,3- 4 ,C- % ,&- 1) ". What !ill be the output of the follo!ing statements ? int i 8 1+H9 H8i>>> >29 printf,EFdE+H-9 ,<- 2rror ,3- 2 ,C- 3 ,&- >3 $. <rray passed as an argument to a function is interpreted as ,<- <ddress of the array ,3- 4alues of the first elements of the array ,C- <ddress of the first element of the array ,&- Iumber of element of the array %. 6he si'e of a structure can be determined by ,i- si'e of *ariable name ,ii- si'e of ,struct tag,<- Jnly ,i,3- Jnly ,ii- ,C- 3oth ,i- and ,ii- ,&- none of these (. do !hile loop is e7ecuted
&epartment of C12+ 34C College of 2ngineering 5age 2

,<- at least once

,3- once

,C- more than once ,&- Ione of these

1). Considering the follo!ing program fragment+ the correct *alues of a and c areK main,D int a+b+c9 b829 a82.,b;;-9 c82.,;;b-9 G ,<- a84+c8" ,3- a83+c8% ,C- a83+b8" ,&- a84+c8% 11. o! many times !ill the follo!ing loop be e7ecuted? ch80b09 !hile,chC80a0 ## ch:80'0ch;;9 ,<-) ,3-25 ,C-2" ,&-1 12. main() { int const * p= ! printf("#$"%&&(*p))! ' 1(. main() { char s) *="man"! int i! for(i=+!s) i *!i&&) printf(",n#c#c#c#c"%s) i *%*(s&i)%*(i&s)%i)s*)! ' 1-. main() { float me = 1.1! $ou.le you = 1.1! if(me==you) printf("/ love 0")! else printf("/ hate 0")! ' 1 . main() { static int var = ! printf("#$ "%var11)! if(var) main()!
&epartment of C12+ 34C College of 2ngineering 5age 3

' 12. main() { int c) *={2.3%(.-%-%2.4% '! int 5%*p=c%*6=c! for(5=+!57 !5&&) { printf(" #$ "%*c)! &&6! ' for(5=+!57 !5&&){ printf(" #$ "%*p)! &&p! ' ' 14. main() { extern int i! i=2+! printf("#$"%i)! ' 13. main() { int i=11%5=11%8=+%l=2%m! m=i&&&&5&&&&8&&99l&&! printf("#$ #$ #$ #$ #$"%i%5%8%l%m)! ' 1:. main() { char *p! printf("#$ #$ "%sizeof(*p)%sizeof(p))! ' 2+. main() { printf("#x"%1177-)! '

&epartment of C12+ 34C College of 2ngineering

5age 4

Vous aimerez peut-être aussi