Вы находитесь на странице: 1из 24

Unit 3 CF QB

1. Two dimensional arrays are also called A tables arrays B matrix arrays C both of A & B D none of above Answer C 2. What is the output of the following code? # include<stdio.h> # define a 10 main() { printf("%d..",a); foo(); printf("%d",a); } void foo() { #undef a #define a 50 } A 10..10 B 10/01/50 C Error D 0 Answer A 3. The syntax of the array declaration is: A datatype nameofarray [size]; B nameofarray [size]; C datatype nameofarray D all of above Answer A 4. int j[4] the size of (j) and size of (int) will display the value A 8,2 B 2.8 C 2,2

D 1,1 Answer A 5. How many time the following function be called main( ) { int j; j=10; fun(j); } fun(int j) { if(j!=5) fun(j-1); } A 10 times B 5 times C 6 times D Infinite loop Answer B 6. Which is the true statement about an array? A To represent an array keyword array is used. B Array elements can be accessed by the index placed within[]. C Array is a collection of similar type of elements. D Both B & C. Answer D 7. Function name refers to A Name given to variables. B Name given to main function. C Name given to function within main function. D None of these. Answer C 8. Which is the calling function? A largest(a,b); B largest(int a, int b) C largest(int, int); D largest(*a, *b); Answer A

9. Which of the following is false about functions ? A More that one function allowed in a program B A function can call itself C Constants can appear in the formal argument list D A function can call another function Answer C 10. What will be the output of the program? #include<stdio.h> int fun(int i) { i++; return i; } int main() { int fun(int); int i=3; fun(i=fun(fun(i))); printf("%d\n", i); return 0; } A 5 B 4 C Error D Garbage value Answer A 11. Every executable C program must contain a A printf function B scanf, printf and main functions C main function D scanf function Answer C 12. Two dimensional array elements are stored in A System dependent.

B In row major dependent. C Compiler dependent D In column major dependent. Answer C 13. Array elements are stored in A Sequential memory locations. B scattered memory locations C Direct memory locations. D random memory locations Answer A 14. Identify the incorrect declaration of arrays from the following A int a[50]; B float values[10][20]; C double a[50]; D int score[10,15]; Answer D 15. Array is used to represent the following A A list of data items of different data types. B A list of data items of real data type. C A list of data items of same data type. D A list of data items of integer data type. Answer C 16. Arrays are passed to a function arguments by A Value. B Reference. C Both value & reference D None of the above. Answer C 17. An array a[8] will store how many values ? A 8 B 7 C 9 D 0 Answer A 18. If an array is declared as a[10], then its elements will be stored as

A a[1] to a[10]. B a[1] to a[9]. C a[0] to a[9]. D a[0] to a[10]. Answer C 19. Recursion always requires ? A Termination of the algorithm B Key variable C Base value D All of these Answer D 20. In int k[4] the total memory occupied by the array is A 32 B 8 C 4 D 2 Answer B 21. One dimensional array needs only subscript. A one B Two C both of the first two D none of the first two Answer A 22. What will be the output of the program? #include<stdio.h> int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } A 2, 1, 15

B 1, 2, 5 C 3, 2, 15 D 2, 3, 20 Answer C 23. What will be the output of the program? #include<stdio.h> int main() { int arr[1]={10}; printf("%d\n", arr[0]); return 0; } A 1 B 10 C 0 D 6 Answer B 24. What will be the output of the program ? #include<stdio.h> int main() { float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d\n", sizeof(arr)/sizeof(arr[0])); return 0; } A 5 B 4 C 6 D 7 Answer B 25. What will be the output of the program if the array begins 1200 in memory? #include<stdio.h> int main() { int arr[]={2, 3, 4, 1, 6}; printf("%u, %u, %u\n", arr, &arr[0], &arr); return 0; } A 1200, 1202, 1204 B 1200, 1200, 1200 C 1200, 1204, 1208

D 1200, 1202, 1200 Answer B 26. Which of the following statements are correct about the program below? #include<stdio.h> int main() { int size, i; scanf("%d", &size); int arr[size]; for(i=1; i<=size; i++) { scanf("%d", arr[i]); printf("%d", arr[i]); } return 0; } A The code is erroneous since the subscript for array used in for loop is in the range 1 to size. B The code is erroneous since the values of array are getting scanned through the loop. C The code is erroneous since the statement declaring array is invalid. D The code is correct and runs successfully. Answer C 27. Which of the following statements are correct about an array? 1: The array int num[26]; can store 26 elements. 2: The expression num[1] designates the very first element in the array. 3: It is necessary to initialize the array at the time of declaration. 4: The declaration num[SIZE] is allowed if SIZE is a macro. A 1 B 1,4 C 2,3 D 2,4 Answer B 28. Array is preferred to be used to hold ? A Constants B Data of same type C Data of different type D None of these Answer B 29. Choose the correct option from below. Any C program

A Must contain at least one function. B Need not contain any function. C Needs input data. D None of the above. Answer A 30. int x[3]; the base address of x is 65460 the elements are stored at locations A 65460, 65462, 65464 B 65460, 6546165462 C 65460, 65464, 65468 D 65460, 65460, 65460 Answer A 31. int cal_sum(int a, int b); In the above example int at the beginning indicates A Name of the function. B Return type of the function. C Both function arguments are integer. D None of the above options. Answer B 32. Return is a statement used to A Return control back to calling function. B Return control & value back to calling fun C Return void. D Return value to the calling function. Answer B 33. A ______________ function is one that returns no value. A Float. B Recursive. C Void. D Integer. Answer C 34. int main(void) { int i=1; while (i<=5)

{ printf("%d",i); if (i>2) goto here; i++; } } void fun() { here: printf("C objective bits"); } Output of above program is A 5 C objective bits B 6 C C objective bits 7 D error Answer D 35. Elements of two dimensional array are stored in ? A Random order B Column major order C Row major order D None of these Answer C 36. In int x[10]; the number 10 specified in the square bracket represents the A 10 addresses B 10 values C 10 lines D None of the above Answer B 37. Each array element stored in separate . A memory Location B pages C directory D None of the above Answer A 38. Any function can be called from any other function. this statement is A neither true nor false.

B true. C false. D true some times. Answer B 39. In a program, A function can be called A only one time. B only once. C any number of times. D only three times. Answer C 40. when compared to call by value, the call by reference is ________ in execution A fast. B neither slow nor fast. C slow. D equal. Answer A 41. Actual and formal parameters must agree in A names and data types. B number of arguments and data types. C names and number of arguments. D data types. Answer B 42. void funct(void) The above function declaration indicates A it returns nothing and no arguments. B it returns nothing and had arguments. C it returns a value and had arguments. D it returns a value and no arguments. Answer A 43. If the number of actual arguments are not matching with formal arguments then A no error. B compiler error. C logical error. D Run time error .Answer B

44. It is necessary to declare the return type of a function in the calling program if the function A Returns an integer B Returns a non-integer value C Is not defined in the same file D None of these Answer B 45. Use of functions A helps to avoid repeating a set of statements many times B enhances the logical clarity of the program C helps to avoid repeated program across programs D all of the above Answer D 46. What will be the output of the program in Turbo C (under DOS)? #include<stdio.h> int main() { int arr[5], i=0; while(i<5) arr[i]=++i; for(i=0; i<5; i++) printf("%d, ", arr[i]); return 0; } A 1, 2, 3, 4, 5, B Garbage value, 1, 2, 3, 4. C 0, 1, 2, 3, 4, D 2, 3, 4, 5, 6, Answer B 47. In array declaration int a[5]; 5 indicatesA Subscript of array a. B Number of elements that array a can stored C Memory require by array a D All of the above Answer B 48. How many times the program will print "HELLO" ? #include<stdio.h>

int main() { printf("HELLO"); main(); return 0; } A Infinite times B 32767 times C 65535 times D Till stack overflows Answer D 49. If you dont initialize a static array, what will be element set to? A 0 B An undefined value C A floating point D \0 Answer A 50. Which of the following statements are correct about the program? #include<stdio.h> int main() { printf("%p\n", main()); return 0; } A It prints garbage values infinitely B Runs infinitely without printing anything C Error: main() cannot be called inside printf() D Compilation Error Answer B 51. There is a error in the below program. Which statement will you add to remove it? #include<stdio.h> int main() { int a; a = f(10, 3.14); printf("%d\n", a); return 0; } float f(int aa, float bb)

{ return ((float)aa + bb); } A Add prototype: float f(aa, bb) B Add prototype: float f(int, float) C Add prototype: float f(float, int) D Add prototype: float f(bb, aa) Answer B 52. Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; } A The function calculates the value of 1 raised to power num. B The function calculates the square root of an integer C The function calculates the factorial value of an integer D None of above Answer C 53. Functions cannot return a floating point number A TRUE B FALSE C Cant Predict D None of above Answer B 54. The index value of any array starts from ? A 1 B -1 C 0 D none of these Answer C 55. 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 Run time error C No Error D Compilation error Answer C 56. What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes? #include<stdio.h> int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u\n", a+1, &a+1); return 0; } A 65474, 65476 B 65480, 65496 C 65480, 65488 D 65474, 65488 Answer B 57. In C, if you pass an array as an argument to a function, what actually gets passed? A Value of elements in array B First element of the array C Base address of the array D Address of the last element of array Answer C 58. Choose the correct statements A Strictly speaking C supports 1-dimensional arrays only B An array element may be an array by itself C Array elements need not occupy contiguous memory locations D Both (A) and (B) Answer D 59. Choose the correct statements A an entire array can be passed as an argument to a function B a part of an array can be passed as argument to a function C any change done to an array that is passed as an argument to a function will be local to the function. D Both (A) & (B) Answer D

60. Choose the correct statements A Array stores data of the same type B Array can be a part of a structure C Array of structure is allowed D All of the above Answer D 61. Choose the statement that best defines an array A It is a collection of items that share a common name. B It is a collection of items that share a common name and occupy consecutive memory location C It is a collection of items of the same type and storage class that share a common name and occupy consecutive memory locations. D None of above. Answer C 62. C does no automatic array bound checking. This is A TRUE B FALSE C C's asset D None of the above Answer A 63. Consider the array definition int num [10] = {3, 3, 3}; Pick the Correct answers A num [9] is the last element of the array num B The value of num [ 8] is 3 C The value of num [ 3 ] is 3 D None of the above Answer A 64. The values within [ ] in array declaration is used to specify ? A Size of array B Largest subscript value C both a and b D None of these Answer A 65. What will be the output of the following program? # include<stdio.h>

void display(); int main() { printf(Hello); display(); return 0; } void display() { printf(Welcome); main(); } A Hello Welcome B Welcome Hello C No output D Both messages will get printed infinitely Answer D 66. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(void) { int array[3]={5}; int i; for(i=0;i<=2;i++){ printf("%d ",array[i]); }} A 5 garbage garbage. B 5 0 0. C 5 null null. D Compiler error. Answer B 67. Which of the following statements are correct about 6 used in the program? int num[6]; num[6]=21; A In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type. B In the first statement 6 specifies a array size, whereas in the second statement it specifies a particular element of array. C In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size. D In both the statement 6 specifies array size.

Answer B 68. If an array is declared as int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be ______ A 3, 2 B 0, 2 C 3, 0 D 0, 4 Answer C 69. The names of variables,functions,arrays are known as A keywords B identifiers C names D elements Answer B 70. Array is a ... ? A Linear data structure B non linear data structure C complex data structure D none of these Answer A 71. If an array is declared as " int a[10] " which of the following is wrong ? A a[-1] B a[0] C a[10] D ++a Answer A 72. The parameters of the called function are called A casual parameters. B formal parameters. C usual parameters. D actual parameters. Answer B 73. The names of actual parameters and formal parameters A almost same. B should be same.

C always same. D need not be same. Answer D 74. Which is not a proper prototype? A int funct(char x, char y); B double funct(char x) C void funct(); D char x(); Answer B 75. What is the return type of the function with prototype: "int func(char x, float v, double t);" A char B int C float D double Answer B 76. Which of the following is a valid function call (assuming the function exists)? A funct; B funct x, y; C funct(); D int funct(); Answer C 77. Which of the following is a complete function? A int funct(); B int funct(int x); {} C void funct(int) { printf( "Hello"); D void funct(x) { printf( "Hello"); } Answer D 78. What is the index number of the last element of an array with 29 elements A 29 B 28 C 0 D Programmer-defined Answer B

79. Which of the following is a two-dimensional array? A array anarray[20][20]; B int anarray[20][20]; C int array[20, 20]; D char array[20]; Answer B 80. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements? A foo[6]; B foo[7]; C foo(7); D foo; Answer A 81. Which of the following gives the memory address of the first element in array foo, an array with 100 elements? A foo[0]; B foo; C &foo; D foo[1]; Answer B 82. Is there any difference in the following declarations? int myfun(int arr[]); int myfun(arr[20]); A Yes B No C D Answer B 83. Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others. A Yes B No C D Answer B 84. If no_______statement appears in a function definition, control automatically returns to

the calling function after the last statement of the called function is executed: A Return B Void C main D None of these Answer A 85. Array passed as an argument to a function is interpreted as A Address of the array B Values of the first elements of the array. C Address of the first elements of the array D Number of element of the array Answer C 86. Which is the false statement: A An array of characters is called string. B Array can be passed to function. C Array is always reference type. D None of these Answer D 87. 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 The compiler would report an error. C The program may crash if some important data gets overwritten. D The array size would appropriately grow. Answer C 88. Maximum number of elements in the array declaration int a[5][8] is A 28 B 32 C 40 D 35 Answer C 89. If the size of an array is less than the number of initialization then A Extra values are beingIgnored B Generates an error message C Size of array is increased

D Size is neglected when values are given Answer B 90. What will be the output for (i = 0; i<10; i++) { temp = a[i]; a[i] = b[i] = temp; } A Interchanges value of array a & b B Syntax error C Only first element of array a and b interchanged D First array copied in second array Answer D 91. A character array always ends with A Null \0' character B Next value of array size C Question mark D None of the above Answer A 92. Variables which are defined inside function are called as A Local variables B Static variables C Global variables D None of above Answer A 93. The smallest element of an array's index is called as A Lower bound B Upper bound C Range D extraction Answer A 94. The array of characters is called _________ A String B null C char D None Answer A 95. The ______ tells the compiler that we are dealing with array

A Brackets( [ ]) B Parenthesis ( ) C Comma ( ,) D None Answer A 96. Array can be sorted by using: A Bubble Sort B Merge Sort C Quick Sort D All of above Answer D 97. _________ is used to store more than one value at a time in a single variable A Array B Pointer C Structure D None Answer A 98. The two dimensional array is called _____ A matrix B inverse C one-dimensional D None Answer A 99. The array elements have been stored and accessed _____ A Row wise B Column wise C diagonally D A& B Answer D 100. What will happen if you assign values in few locations of an array? A Rest of the elements will be set to 0 B Complier error message will be displayed C Possible system will crash

D None of Above Answer A 101. What will be the output of the following program Void main () int al[5]={1}; int b=0,k=0; clrscr(); for(b=0;b<=4;b++) { printf(%3d,++al[0]); } } A 2 3456 B 12345 C 111111 D 122222 Answer A 102. What will be the output of the following program? void main () { int j[]={5,1,2,5,4,8}; int m[]={1,5,8,4,5,9}; int n[]={1,2,9,1,5,9},k; for(k=0;k<6;k++) n[k]=j[k]+m[k]-n[k]; clrscr(); for(k=0;k<6;k++) printf(%d,n[k]); } A 541848

B 551849 C 125559 D 998554 Answer A 103. What is the output of the following program? void main () { int j[]={15,11,17,15,14,18}; int m[]={1,5,8,4,5,9}; int l[]={1,2,,1,5,9},k; for(k=0;k<6;k++) l[k]=j[k]-m[k]/l[k]; clrscr(); for(k=0;k<6;k++) printf(%d,l[k]); } A 14 9 17 11 13 17 B 12 8 16 10 12 16 C 14 19 17 10 12 11 D 44 49 57 60 82 11 Answer A

Вам также может понравиться