Vous êtes sur la page 1sur 7

Synergy 2011

Knight coders-prelims
Read the following instructions carefully 1. 2. 3. 4. 5. 6. 7. This question paper contains 40 questions. Each question carries equal mark. Answer all the questions and justify your answer. Without justification no marks will be rewarded. There will be no negative marking. There is no case sensitive error. It may be printing mistake if you find capital word in the code. Write your registration number, name, branch, year and college name on the answer sheet. Mail your answer sheet on this mail id. knightcoders2011@gmail.com before 8 am. In case of a tie, submission time will be considered.

1. The following truth table is given what is Y equal to? ABCY 0001 0011 0100 0110 1000 1010 1101 1111 2. The Primary purpose of Operating system is..? 3. Is the following code legal? Whether Y/N , justify your answer. struct a { int x; struct a *b; } 4. Is the following code legal? Whether Y/N, justify your answer. typedef struct a { int x; aType *b; }aType

5. What is the output of the following code? is the code is legal? Explain. void main() { printf(sizeof (void *) = %d \n, sizeof( void *)); printf(sizeof (int *) = %d \n, sizeof(int *)); printf(sizeof (double *) = %d \n, sizeof(double *)); printf(sizeof(struct unknown *) = %d \n, sizeof(struct unknown *)); } 6. char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? a) gets(inputString) b) fgets(inputString, sizeof(inputString), fp) 7. Which version do you prefer of the following two? a) printf(%s,str); // or the more curt one b) printf(str); 8. What is the output of the following code? Is the code is legal? Explain. main() { char a[4]="HELL"; printf("%s",a); } 9. Is there any error in program if yes what is the error if not write down the output?

main() { char a[4]="HELLO"; printf("%s",a); } 10. What is the output of the following code? Explain #define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(The dimension of the array is %d, DIM(arr, int)); }

11. What is the output of the following code? Explain.


main() { printf("%x",-1<<4); }

12. What is the output of the following code? Explain. main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); *ptr++; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); *++ptr; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); ++*ptr; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); } 13. What is the output of the following code? Explain. #include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); } 14. What is the output of the following code? Explain. main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); } 15. What is the output of the following code? Explain. main() { unsigned int i=10; while(i-->=0) printf("%u ",i); } 16. What is the output of the following code? Explain. main() { float f=5,g=10; enum{i=10,j=20,k=50};

printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); } 17. What is the output of the following code? Explain. #ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); } 18. What is the output of the following code? Explain. #If something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); } 19. What is the output for the following program? Explain. main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); } 20. What is the output of the following code? Explain. void main() { if(~0 == (unsigned int)-1) printf(You can answer this if you know how values are represented in memory); } 21. What is the output of the following code? Explain. main() { int i=5; printf(%d,i=++i ==6); } 22. What is the output of the following code? Explain.

main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); } 23. What is the output of the following code? Explain. main() { while (strcmp(some,some\0)) printf(Strings are not equal\n); } 24. What is the output of the following code? Explain. main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } } 25. Is the following code legal? Explain. struct a { int x; struct a b; } 26. What is the output of the following code? Explain. #define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); } 27. What is the output of the following code? Explain. char *someFun1()

{ char temp[ ] = string"; return temp; } char *someFun2() { char temp[ ] = {s, t,r,i,n,g}; return temp; } int main() { puts(someFun1()); puts(someFun2()); } 28. Which is the parameter that is added to every non-static member function when it is called? 29. What is the output of the following code? Explain. const int size = 5; void print(int *ptr) { cout<<ptr[0]; } void print(int ptr[size]) { cout<<ptr[0]; } void main() { int a[size] = {1,2,3,4,5}; int *b = new int(size); print(a); print(b); } 30. What is the output of the following code? Explain main() { char str1[] = {s,o,m,e}; char str2[] = {s,o,m,e,\0}; while (strcmp(str1,str2)) printf(Strings are not equal\n); } 31. Can we do binary search on a link list. Justify your answer. 32. How would you find out if one of the pointers in a link list is corrupted or not? 33. Write your own Copy () function. [Note: Dont see it from Internet it should be your creation.] 34. Can we do binary search, if we divide the whole list in 1/3 and 2/3 in place of finding the middle of the list. If YES than what will be the effect of this on complexity. Or if you say NO than justify your answer.

35. What should be the complexity of deleting a number from link list, if you first insert it to the stack and than delete it and again insert it to link list. 36. What is Tail call? Explain it in 5 words only. 37. What is the difference between pseudo code and Program? 38. How many pointers at least you need, to reverse a link list. 39. Which sorting is better quick sort / heap sort? Justify your answer. 40. How can I sort things that are too large to bring into memory? If yes than which sorting you are going to used.

Vous aimerez peut-être aussi