30 likes | 54 Views
Avatto provide practice C programming Multiple Choice questions with answers for the preparation of various competitive and academic exams. Visit now!<br>
E N D
C Programming Online Test 1 11/28/13 Computer Science - Computer Science Online Test - C Programming - Arrays 1 No.Question 1 O(N)(linear time) is better than O(1) constant time. A B C D True False 2 For 'C' programming language A B C D Constant expressions are evaluated at compile String constants canbe concatenated at compile time Size of arrayshould be knownat compile time All of these 3 If x is an array of interger, then the value of &x[i] is same as A B C D &x[i-1] + sizeof (int) x+ sizeof (int) * i x+i none of these 4 Size of the array need not be specified, when 5 Minimum number of interchange needed to convert the array 89,19,40,14,17,12,10,2,5,7,11,6,9,70, into a heap with the maximum element at the root is Avatto.com A B C D Initializationis a part of definition It is a declaratrion It is a formal parameter All of these A B C D 0 1 2 3 6 Minimun number of comparison required to compute the largest and second largest element in array is n-[log₂n]-2 B n+[log₂n-2] C log₂n D None of these A 7 The minmum number of inter changes needed to convert the array 89,19,40,17,12,10,2,5,7,11,6,9,70 into a heap with maximum element at the root is A B C D 1 2 4 None of these 8 Choose the correct statements A All The elements of the arrayshould be of the same data type and storage class The number of subscripts determines the dimensionof the array The arrayelements need not be of the same storage class Inanarraydefinition. the subscript canbe anyexpression yielding a non-zero integer value B C D 9 Consider the array definition int num [10] = {3, 3, 3}; Pick the Correct answers A B C D num [9] is the last element of the arraynum The value of num [ 8] is 3 The value of num [ 3 ] is 3 None of the above 10 While passing an array as an actual argument, the function call must have the array name A B C D withemptybrackets withits size alone none of the above 11 The parameter passing mechanism for an array is A call byvalue 1/2 Get UGC NET, GATE, Teaching Aptitude, Reseach Aptitude, Computer Quiz and Aptitude Questions Answers
C Programming Online Test 2 11/28/13 B C D call byvalue-result call byreference none of these 12 The maximum number of dimension an array can have in C is A B C D 3 4 5 compiler dependent 13 If a two dimensional array is used as a formal parameter, then A B C D boththe subscripts maybe left empty the first (row) subscript maybe left empty the first subscript must be left empty boththe subscripts must be left empty 14 C does no automatic array bound checking. This is A true B C D false C's asset C's shortcoming Avatto.com 15 If n has the value 3, then the statement a [++n]= n++ ; A B C D assigns 3 to a [5] assigns 4 to a [5] assigns 4 to a [4] what is assigned is compiler-dependent 16 Choose the correct statements A B C Strictlyspeaking C supports 1-dimensional arrays only Anarrayelement maybe anarraybyitself Arrayelements need not occupycontiguous memory locations Both(a) and (b) D 17 If arr is a two dimensional array of 10 rows and 12 columns, then arr (5) logically points to the A B C D sixthrow Fifthrow fifthcolumn sixthcolumn 18 Choose the correct statements A B C anentire arraycanbe passed as an argument to a function a part of anarraycanbe passed as argument to a function anychange done to anarraythat is passed as anargument to a functionwill be local to the function Both(a) & (b) D 19 Choose the correct statements A B C D Arraystores data of the same type Arraycanbe a part of a structure Arrayof structure is allowed All of the above 20 Consider the declaration char street[10] = "abcdefghi"; Choose the correct remark(s) A B C &street and street will have different values &street is meaningless &street+1 and street+1 will have the same values D None of the above 2/2 Get UGC NET, GATE, Teaching Aptitude, Reseach Aptitude, Computer Quiz and Aptitude Questions Answers
C Programming Online Test 3 Computer Science - Computer Science Test - C Programming - Arrays 1 Answers 1 B 2 D 3 A 4 D 11 C 12 D 13 B 14 D 5 C 15 D 6 B 16 D 7 B 17 A 8 B 18 D 9 A 19 D 10 C 20 D Answers Explanation Explanation X+i means increment in value of X not in address of X so it cant represent address of X. &x[i] means address of the ithelement. So & X[i-1] defines address of i-1 element .sizeof(int) defines size of an element So &x[i-1] + sizeof(int) means address of i-1 element plus size of an element that means address of ith element. It cant be option c as x+i is not representing any address. X+i means increment in value of X not in address of X so it cant represent address of X. So option (A) is correct Avatto.com 3 4 Explanation Consider the following declaration double balance[] = {1000.0, 2.0, 3.4, 17.0, 50.0}; If you omit the size of the array, an array just big enough to hold the initialization is created. So, correct option is 'A'. 5 Explanation Only element 70 violates the rule. Hence, it must be shifted to its proper position. Step1: swap(10, 70) Step2: swap(40, 70) Hence, only 2 interchanges are required. 14 Explanation C does no array bound checking. Because of this, one can access fifth clement of an array that is declared to he of lesser size. 16 Explanation C supports 1-dimensional arrays only. But, the array element can be an array by itself. Using this, one can simulate multi-dimensional arrays. Though at the user level, we use 2-dimen- sional arrays, the compiler interprets this as a 1-dimensional array, each of whose element is a 1-dimensional array. As a matter of fact, a declaration like char [3] [4] , will be interpreted as a 1-dimensional array of size 3 (rather than 4)—each element being a character array of length 4. 20 Explanation &street and street will have the values which is the starting address of the street array. However. street is a pointer to the first character whereas &street is a pointer to the entire array. The incremented values of street and &street reflects this difference. Get UGC NET, GATE, Teaching Aptitude, Reseach Aptitude, Computer Quiz and Aptitude Questions Answers