cf chap3 engineering mcq's
TRANSCRIPT
-
7/28/2019 Cf chap3 engineering mcq's
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# define a 10main(){
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 A4. int j[4] the size of (j) and size of (int) will display the value
A 8,2
B 2.8
C 2,2
-
7/28/2019 Cf chap3 engineering mcq's
2/24
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 timesC 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
-
7/28/2019 Cf chap3 engineering mcq's
3/24
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
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.
-
7/28/2019 Cf chap3 engineering mcq's
4/24
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
-
7/28/2019 Cf chap3 engineering mcq's
5/24
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?#includeint 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
-
7/28/2019 Cf chap3 engineering mcq's
6/24
B 1, 2, 5
C 3, 2, 15
D 2, 3, 20
Answer C
23. What will be the output of the program?#includeint 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 ?#includeint 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?#includeint 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
-
7/28/2019 Cf chap3 engineering mcq's
7/24
D 1200, 1202, 1200
Answer B
26. Which of the following statements are correct about the program below?#includeint main(){
int size, i;scanf("%d", &size);int arr[size];for(i=1; i
-
7/28/2019 Cf chap3 engineering mcq's
8/24
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
-
7/28/2019 Cf chap3 engineering mcq's
9/24
{ 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.
-
7/28/2019 Cf chap3 engineering mcq's
10/24
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 A43. 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
-
7/28/2019 Cf chap3 engineering mcq's
11/24
44. It is necessary to declare the return type of a function in the calling program if thefunction
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)?#includeint main(){
int arr[5], i=0;while(i
-
7/28/2019 Cf chap3 engineering mcq's
12/24
int main(){
printf("HELLO");main();return 0;
}
A Infinite timesB 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?#includeint 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
int main(){
int a;a = f(10, 3.14);printf("%d\n", a);return 0;
}float f(int aa, float bb)
-
7/28/2019 Cf chap3 engineering mcq's
13/24
{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
-
7/28/2019 Cf chap3 engineering mcq's
14/24
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?#includeint 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 thefunction.
D Both (A) & (B)
Answer D
-
7/28/2019 Cf chap3 engineering mcq's
15/24
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 memorylocation
C It is a collection of items of the same type and storage class that share a common nameand occupy consecutive memory locations.
D None of above.
Answer C62. 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
-
7/28/2019 Cf chap3 engineering mcq's
16/24
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
int main(void){int array[3]={5};int i;for(i=0;i
-
7/28/2019 Cf chap3 engineering mcq's
17/24
Answer B
68. If an array is declared asint 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.
-
7/28/2019 Cf chap3 engineering mcq's
18/24
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
-
7/28/2019 Cf chap3 engineering mcq's
19/24
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 with100 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, anarray 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
-
7/28/2019 Cf chap3 engineering mcq's
20/24
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 whosesubscript 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
-
7/28/2019 Cf chap3 engineering mcq's
21/24
D Size is neglected when values are given
Answer B
90. What will be the outputfor (i = 0; i
-
7/28/2019 Cf chap3 engineering mcq's
22/24
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-dimensionalD None
Answer A
99. The array elements have been stored and accessed _____
A Row wise
B Column wise
C diagonally
D A & B
Answer D100. 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
-
7/28/2019 Cf chap3 engineering mcq's
23/24
-
7/28/2019 Cf chap3 engineering mcq's
24/24
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