7
** Pre-Placement Paper : Technical Max-Marks : 30 Time : 30 Min 1. int main(){ int a = 320; int *ptr; ptr =( char *)&a; printf("%d ",*ptr); return 0; } A. 320 B. 64 C. Compilation Error D. None of the above 2. int main(){ int i=13, *j, k; j = &i; printf("%d\n", i**j*i+*j); A. 2210 B. Compilation error C. 30 D. 13 3. int main(){ void (*p)(); int (*q)(); int (*r)(); p = clrscr; q = getch; r = puts; (*p)(); (*r)("Our respected seniors"); (*q)();} A. NULL B. Our respected seniors C. C D. Compilation error 4. main(){ int i; double a=20.2; char *ptr;

Technical test in unit1 for C

Embed Size (px)

DESCRIPTION

Technical test in unit1 for C

Citation preview

Page 1: Technical test in unit1 for C

** Pre-Placement Paper : Technical Max-Marks : 30 Time : 30 Min

1. int main(){

int a = 320;

int *ptr;

ptr =( char *)&a;

printf("%d ",*ptr);

return 0; }

A. 320 B. 64 C. Compilation Error D. None of the above

2. int main(){

int i=13, *j, k;

j = &i;

printf("%d\n", i**j*i+*j);

A. 2210 B. Compilation error C. 30 D. 13

3. int main(){ void (*p)();

int (*q)(); int (*r)();

p = clrscr; q = getch;

r = puts; (*p)();

(*r)("Our respected seniors");

(*q)();}

A. NULL B. Our respected seniors

C. C D. Compilation error

4. main(){ int i; double a=20.2; char *ptr;

ptr=(char *)&a;

for(i=0;i<=7;i++)

printf("%d ",*ptr++);}

Page 2: Technical test in unit1 for C

(a) -51 -52 -52 -52 -52 -52 20 64 (b) 51 51 51 51 51 51 52 64

(c) Eight garbage values. (d) Compiler error

5. It is necessary for a function to return some value

a. True b. False

6. A Pointer to void can hold pointer to…………………………………..,

7. . What will happen if you try to put so many values into an array when you initialize itthat the size of the array is exceeded?

a. Nothing b. possible system malfunctionc. Error message from the compiler d. Other data may be overwritten

8. …….. arguments used in a function can be variables, constants or expressions.

9. int main(){

Printf(“%c\n”,7[“Pondicherry”]);

return 0;}

a) h b) e c) pondich d) none of these

10. In C, you pass an array as an argument to a function, what actually gets passed?

A) Base address of the array.

B) Number of elements of the array.

C) First element of the array.

D) Last element of the array.

11. Where can we use pointers ?

a) Accessing array or string elements.b) Dynamic memory allocation.c) Static memory allocation.d) Implementing linked list, trees and other data structures.A. TTFT B. TFTT C. FFTF D. TFTF

12. int main(){

charstr[]= “peace”; char * s= str;

printf(“%s\n”,s++ +3);}

Page 3: Technical test in unit1 for C

a) peace b)ace c) ce d) none of these

13. A function may be called more than once from any other function.

A. true b. false

14. Each Pointer is …………………………………. to the variable to which it points.

15. …….. keyword is used to transfer control from a function back to the calling function.

16. In which of the following cases mentioning the name of the array does not yield the base address?

A. When array name is used with the sizeof operator.

B. When array name is operand of the & operator.

C. When array name is passed to scanf() function.

D. When array name is used in arithmetic operations.

a. A b. A,B c. A,B,C d. A,B,D

17. int fun(){

c = 1990;}

int main(){

int fun(); int i;

i = fun(); printf("%d\n", i);}

a. 1990 b. o c. garbage value d. compilation error

18. Point out the error in following source code

f(int a, int b){int a; a = 20;return a;}

a. Missing parenthesis in return statementb. The function should be defined as int f(int a, int b)c. Redeclaration of ad. None of above

Page 4: Technical test in unit1 for C

19. An ………………………………variable comes into existence when the function in which it is declared is executed.

20. Which one of the following does not represent a valid storage class I ‘C’?a. automatic b. static

c. extern d. union

21. int i;int fun();int main(){while(i) {

fun();main();}

printf("Hello\n");}int fun(){printf("Hi");}

a. HELLO b. Hello c. Hi Hello d. No output

22. Recursive functions are executed in a

a. LIFO order b. FIFO order

c. Parallel fashion d. any one of the above

23. If we define an array in a function with ………………………..class, we cannot pass address of that array back to the main of subsequent work.

24. void fun(int **p){

printf("%d\n", **p);}

main(){

int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};

int *ptr; ptr = &a[0][0];

fun(&ptr); }

a. 12 b. 21 c. 1 d. None of these

25. int main(){int x=0, *y, *z; y=&x; /* Assume address of x is 500 and integer is 4 byte size */z=y; *y++=*z++; x++;printf("x=%d, y=%d, z=%d\n", x, y, z);}

Page 5: Technical test in unit1 for C

a. 21, 2686792, 2686792 b. 21, 21, 21 c. 2686792, 2686792, 268679226. One way pointer s are useful to refer to a memory address that has no…………………………….,

27. Which variable type holds at a common assigned area different data types of

Varying sizes at different points in time?

a. struct b. union

c. enum d. none of the above

28. int main(){int ***r, **q, *p, i;p = &i; q = &p; r = &q;printf("%d, %d, %d\n", *p, **q, ***r);}

a. 35,35,35 b. 0, 0, 0 c. compilation error d. no output

29. int main(){char a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};printf("%d, %c\n", a, &a+1);}

a. 2686768 , 0 b. 2686768, 2686768 c. 2686768, < d. No output

30. The rand function is defined in…………………31. Which of the following types cannot be returned by a function?

a. pointer to an array b. pointer to a pointerc. an array of integer d. an unsigned integer

32. An array may contain elements of different types.

a. True b. False

33. int main(){

intarr[1]={};

printf("%d\n", 0[arr]);}

a. 0 b. no output c. compilation error d. garbage value34. A pointer to an integer may be multiplied by another integer.

a. True b. False

35. If we define an array in a function with ………………………..class, we cannot pass address of that array back to the main of subsequent work.

Page 6: Technical test in unit1 for C

36. What will happen if you try to put so many values into an array when you initialize itthat the size of the array is exceeded?

a. Nothing b. possible system malfunctionc. Error message from the compilerd. Other data may be overwritten

37. int main(){

char *str; str = "%d\n"; str++; str++;

printf(str-2, 010);}a. 8 b. 010 c . 10. D. 80

38. int main()

{

printf("%c\n", 7[""]);

}

a. Compilation error b. no output c. zero d. None of these

39. state true or false :

a) Every function must return a value.b) Redeclaration of a function is an error.c) Redefinition of a function is an error.d) Name of functions in two different files linked together must be unique.

a) TTFF b) TFTF c) FFTT d)TTFT

40. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

A) The element will be set to 0.

B) Nothing ,it is done all the time.

C) The compiler would report an array.

D) The program may crash if some important data gets overwritten