Round 1: Online testYour Registration id is: 6840 TIME ELAPSED: 0:00:07 Q 1. What is the output of the program? #include <stdio.h> char* f(int* pp) { return (char*)pp; } void main() { int arr[] = {67, 69, 71}; printf(" %s ", f(arr + 1)); } C D E G Q 2. typedef union { unsigned int word; unsigned char test[2]; }test; test p = {576}; What value will p.test[0] and p.test[1] have on little-endian architecture? 2,64 64,2 64,1 None of the above Q 3. Which statement is wrong in C? A pointer to a constant can be used to view but not modify its target A const pointer can't be modified but its target can The inline specifier instructs the compiler to replace function calls with the code of the function body constant pointers to constants can be used to view but not modify its target Q 4. What is the output of the program, if the base address of the array is 1244896? #include <stdio.h> void main() { struct { float c; union p { char c; char *cp; short s; } uvar[5]; } svar[6]; printf("%d %d ", &svar[2], &svar[5]); } 1244784 1244976 1244944 1245016 1244784 1244932 1244944 1244992 Q 5. Consider union AUnion { int a; float b;}; Which of the following are the correct with regard to initializing the given union: union AUnion a = { 10 }; union AUnion a = { 10, 5.5}; union AUnion a = { 5.5}; 1,2,3 1,3 2 1,2 Q 6. Consider the following program Page 1 / 9 p=atoi(argv[1]).static int try ( int x1.*ptr[0]). Which of the following is not the purpose of a call stack? Storing the return address of function Parameter passing Storing static variables Storing local variables value Q 9. printf(“%s”. } The output of the program if the input is: test 800 300 500 800 junk value 0 Q 7. int result. result=try(p. the address contained in the pointer is incremented according to the type it is pointing t Q 10.*(ptr+1)). if(argc!=3) printf(“error”). char *p = “APtr”.q). return 0. printf(“%s”. printf(“%s”. x1 asm sub AX. “world” }. Which statement is correct? When a pointer is incremented by 1. int diff = second . the address contained in the pointer is incremented according to the type of pointer When a pointer is incremented by 1. 2.ptr[0]). 3.h> int main() { char a[] = “ThisArray”. %d”. Which is the output of the following program: #include <stdio. 4}. Q 11.h> #include <string. } main(int argc. int x2) { asm mov AX. *ptr[1]). 1. Page 2 / 9 . the address contained in the pointer is incremented by 1 When a pointer is incremented by 1. } PtrsArray PtrArray TptrArray Error Q 8. register int q. printf(“result = %d”. printf(“%s”. the address contained in the pointer is incremented by size of integer When a pointer is incremented by 1. char * argv[]) { register int p. result). a+1). Correct code to print “hello” of the above code is: printf(“%s”. printf(“%d. What is the output of the following program: #include <stdio. *(integer + diff)). x2 return. return 0.h> int main() { int integer[] = { 0. int *first = integer. integer[0] += diff. “hello”. strcpy(++a. int *second = integer + 1. ++p). q=atoi(argv[2]).first. Consider the following code char *ptr[3] = { “the”. *integer. } 1.. Q 13. b = *p++. Consider the following code: f(unsigned int x. unsigned int y) { while(x!=y) { if(x>y) x-=y.ar. cp = NULL.) = printf. if(cp != NULL) strcpy(cp.arr). cp = NULL.. What is the output of the program? #include <stdio. = {‘a’. Q 14. What is the output of the program? #include <stdio. b = *++p. "hello"). Consider the main() { char ar[3] char arr[] printf(“%s } following program: = {’a’. } printf(“%d”.4 4.h> void main() { char *cp = (char *) malloc(10).1 4. } What does the above code do? Compute the GCD of two numbers Divide the largest number by the smallest number Compute the LCM of two numbers None of the above Q 16.’b’}. *p = a. Which statement is wrong given the following code? int a[] = {5.1 1. if(cp != NULL) free(cp). 7. 9}. b = ++*p * *p++. Given the following code snippet. ab ab ab b Runtime error None of the above Q 15.’b’}. x > y ? y: x ).h> void main() { int (*Commprintf)(const char*. b. } No output Undefined symbol Commprintf Compile Error: Prototype mismatch Hello World Q 17. else y-=x. if(cp != NULL) free(cp).4 Q 12. Commprintf("Hello World"). .h> #define DEBUG 0 void main() { #ifndef DEBUG Page 3 / 9 . // line 3 // line 4 } cp = NULL. if(cp != NULL) free(cp). what statement do we write in line 3 and 4 to ensure there is no lost memory and no dang #include <stdio. b = *++p++. %s”. mov sub.ptr).printf("d1 "). } d1 d3 d2 d4 d2 d3 d1 d4 Q 18. } s %s %d%t%s None of the above Q 21. j. Consider the following program: main() { char *ptr = “%d%t%s”. 'l'. char str1[15] = "All is ". 'l'}. k. #else printf("d2 "). while(*ptr++!=’t’) .eax. #endif if(!DEBUG) printf("d3 ").i. Consider the following program: main() { int i. What is the output of the program? # include <stdio. else printf("d4 "). sub). c = 65. k=0. sub eax. unsigned int j=0x12. {'w'. What is the output of the following program? main() { unsigned int i=0x53. Page 4 / 9 . 'e'. k = (++i)>(++j) ? (i++) : (j++). 'l'. } The output of the above program is: i=12 j=6 k=12 i=12 j=5 k=12 i=12 j=6 k=11 i=12 j=6 k=10 Q 19.j. printf(“i=%d j=%d k=%d”.h> void main() { char str[][5] = {{'h'. bin(c). The output of the following program is main() { unsigned char c. } printf(“%x”. 'e'.j. 'l'}}. *(str+1))). i =10. strcat(strchr(str1. printf(ptr. j=5. printf("%s ". _asm { mov eax. } 64 41 32 66 Q 22. unsigned int sub. i. } lwell llwell ll is well l is well Q 20.k). 'l'). else printf(“0”). a). j[3]=5. n>0. n=n/2) { if(i & n) printf(“1”). What is the output of the program? #include <stdio. printf(“%d %d”. for ( i = 0. } 0 1 1 0 0 0 0 32 Page 5 / 9 . What is the output of the following program: #include <stdio. } The output for the program is: 4 5 6 3 Q 26. } 0 1 2^31-1 2^31 Q 24. } Output of the above code is: 0 5 0 0 5 0 None of the above Q 25.} void bin(unsigned i) { unsigned n=2. Consider the following program: void foo(int[]). i[4]. i[5]). int j = ~0. unsigned int count = 0. if(++a^++a && (a^a) || ++a) printf(“%d”. i--) { count++.h> int main() { int i = 0. count).h> void main() { unsigned char C = 32. } printf(“%u”. i > j. for(n=n<<6. C ^= C . } } 01000001 00000000 11111111 None of the above Q 23. return 0. foo(i). !(C & 128) && !(C & 1)). } void foo(int j[]) { j=j+2. main() { static int i[6]. printf(" %d %d ". Consider the following program: main() { int a=2. printf("%d ". while(b) { b = b ^ a. char c. "HelloWorld"). {20. printf("%d %d". {11. 3.h> void main() { int arr[3][3] = {9. Output is HelloWorld Q 32.h> void main() { int x[3][4] = {{1.h> void main() { char *str = (char *) malloc(100). DEF(i). 4.Q 27. Match the following with reference to the following program code. 14.(char*)((&any) . } i) *(*(x + 1) + 1) 1) 9 Page 6 / 9 . int *ip = *arr. double d. } Gives the address the variable Gives the size of the variable Gives the address of the variable one element prior to the current one Pointer subtraction Q 28. 2}. } } 60 12 15 12 60 0 15 0 Q 31.h> void main() { int a = 4. 18.h> #include <string. 6. printf("%5s". What is the output of the program? #include <stdio. 3. What is the error in the program? #include <stdio. What is the meaning of a static function in C? It is local to a file in which it is declared It is local to main() The set of variables used in the function is 'static' All the linked files can access it Q 29. DEF(d)). } strcpy(str. ++ip[2] + --ip[3]). 12}. printf("%d ". 1}. #include <stdio. 7. str). 5}}. 17. *(++ip)). What is the output of the program? # include <stdio. printf("%d ". DEF(c). b << 2 | b. 16. b = 8. if(str = NULL) { printf(" Memory allocation failed "). 12. } Link error Compilation error Runtime error No error.h> #include <malloc. printf("%d %d %d".1) void main() { int i. break. 9.h> #define DEF(any) (char*)(&any) . 5. 23. int *n = &x. ++ip[4]). } 6 25 16 6 25 18 6 23 18 6 23 16 Q 30. What does the macro definition DEF in the following code do? #include <stdio. b >> 2 & b). return. p2[9] = '\0'. ii – 4. } **arr + 4 + 6 *(*(arr + 2) + 4) **(arr + 3) + 4 *(*(arr + 2) + 3) Q 36. j. i++) { for(j = 0. printf(“%d . char *p2. } AAAAAworda AAAAAwordA AAAAwordA AAwordA AAAAAAAAA AAAAAAAA AAAAAAA AAAAAA AAAAAword AAAAAwor AAAAAwo AAAAAw wordAAAAA wordAAAa wordAAA wordAA Q 35. Page 7 / 9 . ii – 1. ii – 3. p2 = (char *) malloc(10). int val = 1.1 Q 34. memset(p2. iv – 2 Q 33. %d”. for (. } } // printf(" %d ". i. i. int j = 0. int j = 4. iii – 2. } int main() { int i = 0. 10). return (i++). 'A'. k < 2. iii – 2. j = func(i). ii – 1. func(i & j)). iii – 1. for(i = 0.h> void main() { int arr[4][6]. ). j < 6.h> int i = 0. k++) { printf(“%d”. What is the output of the following problem: #include <stdio. j++) { arr[i][j] = ++val. p2). } int main() { int i = 2.ii) *(*x + 1) + 3 iii) *(n + 3) + 1 iv) ++(*n++) + *n 2) 13 3) 4 4) 17 i – 3.1 1. i = init. int k = 0. iv – 1 i – 4. What is the output of the following program: #include <stdio.0 0. which expression will print the value 18 in the commented code? #include <stdio. iii – 1. i < 4. iv – 4 i – 2. What is the output of the program? #include <stdio.0 0. i = i << 1. } 1. iv – 3 i – 4. int func (int j) { return (i = (j += !i)). If "arr" is an array of 4 x 6 dimension.h> int func (int init) { static int i. j).h> main() { char *p1 = "word". while(*p2++ = *p1++) printf("%s ". 75.0 Q 38. What is the output of the following code? #include <stdio. char str1[20] = "C-language-is-fun". const char *).75.h> int main() { int a = 3. What is the output of the following program? #include <stdio. the contents of the file are surrounded with #ifndef (STD) #define STD //program contents… #endif #ifdef (STD) #define STD //program contents… #endif #if !defined(STD) #define STD //program contents… #else #undef STD //program contents #endif None of the above Q 39. 0. return 0. } return 0. float c = a / b.h> #include <string. c). } 00 01 11 12 Q 37. int b = 4. 'e'. float d = (float) (a / b). sizeof(str) . printf(“%f”. What does a C program not contain on the stack at run time? Automatic variable Internal Static (Local to function scope) variable Return address of function function parameter Q 40. What is the output of the program? # include <stdio.0. To make certain that the contents of a file std. 'o'}.h are included only once. 0. {'w'}}. 0.h> int (*pf1)(const char *.0. 0. {'l'. str1.0 0. Page 8 / 9 . strncpy(*str. d).h> void main() { char str[][3] = {{'h'. } C-lan C-l C-langua C-lanuguage-is-fun Q 41. printf(“%f”. } 0.75 0. 'l'}.1)). printf("%s ".75 0.j = j << 1. 44.2 2. 23. Line 5 and Line 6 Line 4.char * (*pf2)(char *. printf(" %d ". // Line 7 } Line 4 Line 4 and Line 5 Line 4. } } 7 8 10 11 7 5 9 6 7 6 9 7 6 7 9 10 Q 44.3 1. printf("%s %d".h> int g = 4. ++g). if(g > 10) break. const char *). Line 6 and Line 7 Submit Page 9 / 9 . "world")).3 1.2. else continue. int *iptr1 = array.3 Q 43. b. strlen(buff)). pf2(buff.h> main() { static int array [] = {1. Consider the following statements: 1)malloc allocates a single memory block of given size 2)malloc initializes the allocated memory space to zero 3)malloc allocates memory from heap Which of the above statements are correct – 1. pf1("hello". pf2 = strcpy. "demo"). What would be the correct declaration for an array of pointers to functions which accept an integer and character as argum float (*func)(int. c. // Line 5 c = iptr2 / 4. g += 2)) { extern int g. Line 5. d. What is the output of the program? #include <stdio. } -1 demo 10 -1 demo 4 1 demo 4 Compilation error as function pf1 and pf2 are undefined Q 42. 61}. char)[] Q 45. while((g <= 8) && printf(" %d ". a = iptr1 * 2. *iptr2 = &array[3]. char) float(*func[])(int . printf("%d ". int main() { char buff[10]. void main() { int g = 5. buff. // Line 6 iptr1 = iptr2. Which of the statements would result in compilation error? Choose the most appropriate? #include <stdio. 12. pf1 = strcmp. char)[] float (func[])(int . char) float(func)(int. // Line 4 b = iptr1 + iptr2. int a.