Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 22

MULTILE CHOICE QUESTIONS (Unit I)

1. The memory address of the first element of an array is called 


(a) floor address (b) foundation address
(c) first address (d) base address
2. Which of the following data structures are indexed structures?
(a) Linear arrays (b) Linked lists
(c) Trees (d) All the above 
3. Which of the following is not the required condition for binary search algorithm?
(a) The list must be sorted
(b) There should be the direct access to the middle element in any sublist
(c) There must be mechanism to delete and/or insert elements in list
(d) None of above
4. Which of the following is not a limitation of binary search algorithm?
(a) Must use a sorted array
(b) Requirement of sorted array is expensive when a lot of insertion and deletions are needed
(c) There must be a mechanism to access middle element directly
(d) Binary search algorithm is not efficient when the data elements are more than 1000.
5. Which of the following data structure can't store the non−homogeneous data elements?
(a) Array of integers (b) Records
(c) Pointers (d) None
6. Which of the following data structure store the homogeneous data elements?
(a) Array of integers (b) Records
(c) Pointers (d) None
7. Which of the given options provides the increasing order of asymptotic complexity of functions
f1, f2, f3 and f4? 
f1(n) = 2n
f2(n) = n3
f3(n) = nlog2n
f4(n) = log2n
(a) f1, f2, f3, f4 (b) f2, f1, f3, f4
(c) f1, f2, f4, f3 (d) f4, f3, f2, f1
8. Which of the given options provides the decreasing order of asymptotic complexity of functions
f1, f2, f3 and f4? 
f1(n) = 1
f2(n) = n2
f3(n) = nlog2n
f4(n) = log2n
(a) f1, f2, f3, f4 (b) f2, f3, f4, f1
(c) f1, f2, f4, f3 (d) f4, f3, f2, f1
9. The following C function, is called as x= f(10, 3). 
int f (int n, int m)
{
if (n%m==0) return m; 
n=n%m;
return f(m,n);
}
What will be value of x?
(a) 1 (b) 10
(c) 3 (d) 30
10. The following C function, is called as x = f(10, 4). 
int f (int n, int m)
{
if (n%m==0) return m; 
n = n%m;
return f(m,n);
}
What will be value of x?
(a) 1 (b) 2
(c) 3 (d) 30
11. The following C function, is called as x= f(4). 
int f(int n)
{
if (n==0) return 0; 
else return (n+f(n−1));
}
What will be value of x?
(a) 1 (b) 10
(c) 15 (d) 30
12. The following C function, is called as x= f(3). 
int f (int n)
{
if (n==0) return 1; 
else return (n*f(n−1));
}
What will be value of x?
(a) 3 (b) 6
(c) 5 (d) 9
13. The following C function, is called as x = f(3). 
int f (int n)
{
if (n==0 || n==1) return n; 
else return (f(n−1)+f(n−2));
}
What will be value of x?
(a) 3 (b) 2
(c) 1 (d) 0
14. The following C function, is called as x= f(34). 
int f (int n)
{
if (n==0) return 0; 
else return (n%10+f(n/10));
}
What will be value of x?
(a) 12
(b) 4
(c) 7
(d) 0
15. The following C function, is called as x = f(3,2). 
int f (int x, int n)
{
if (n==0) return 1; 
else return (x*f(x,n−1));
}
What will be value of x?
(a) 6 (b) 5
(c) 9 (d) 1
16. The following C function, is called as x = f(3). 
int f (int n)
{ int s=0;
for(;n>0;n−−)
s=s+n; 
return (s);
}
What will be value of x?
(a) 6 (b) 5
(c) 3 (d) 1
17. When new data are to be inserted into a data structure, but there is no available space;
This situation is usually called 
(a) underflow (b) overflow
(c) houseful (d) saturated
18. The worst case complexity of binary search algorithm is 
(a) O(n) (b) O(log2n)
2
(c) O(n ) (d) O(1)
19. The worst case complexity of linear search algorithm is 
(a) O(n) (b) O(log2n)
2
(c) O(n ) (d) O(1)
20. The best case complexity of binary search algorithm is 
(a) O(n) (b) O(log2n)
2
(c) O(n ) (d) O(1)
21. The best case complexity of linear search algorithm is 
(a) O(n) (b) O(log2n)
2
(c) O(n ) (d) O(1)
22. Which of the following is true? 
(a) If data are in order binary search is better than linear search
(b) If number of elements in the list are small, linear search is better than binary search
(c) Indexed sequential search requires extra space.
(d) All the above
23. The average successful search time for sequential search on 'n' items is 
(a) (n+1)/2 (b) (n − 1)/2
(c) (n + 2)/2 (d) log(n) + 1
24. Which of the following is best computing time for an algorithm? 
(a) O(n) (b) O(log2n)
(c) O(nlog2n) (d) O(n2)
25. In analysis of algorithm, approximate relationship between the size of the job and the amount of
work required to do is expressed by using 
(a) central tendency (b) differential equation
(c) order of execution (d) order of magnitude
26. If an algorithm has a complexity of 2n 2 + 4n + 3 for some model of computation (some set of
assumptions) and some complexity measures (such as number of comparison operations) we
could say that it has complexity
(a) O(log n) (b) O(n2)
(c) O(2 + 4+ 3) (d) all of the above
27. Two main measures for the efficiency of an algorithm are
(a) processor and memory                    (b) complexity and capacity
(c) time and space                                (d) data and space
28. The time factor when determining the efficiency of algorithm is measured by
(a) counting microseconds                  
(b) counting the number of key operations
(c) counting the number of statements           
(d) counting the kilobytes of algorithm
29. The space factor when determining the efficiency of algorithm is measured by
(a) counting the maximum memory needed by the algorithm
(b) counting the minimum memory needed by the algorithm
(c) counting the average memory needed by the algorithm
(d) counting the maximum disk space needed by the algorithm
30. Which of the following data structure is linear data structure?
(a) Trees     (b) Graphs
(c) Arrays  (d) None of above
31. The operation of processing each element in the list is known as
(a) Sorting  (b) Merging      
(c) Inserting      (d) Traversal
32. Arrays are best data structures
(a) for relatively permanent collections of data
(b) for the size of the structure and the data in the structure are constantly changing
(c) for both of above situations
(d) for none of above situation
33. Linked lists are best suited
(a) for relatively permanent collections of data 
(b) for the size of the structure and the data in the structure are constantly changing
(c) for both of above situations
(d) for none of above situation
34. Which of the following data structures are indexed structures?
(a) Linear arrays (b) Linked lists              
(c) Both of above          (d) None of above 
35. An algorithm that calls itself directly or indirectly is known as
(a)  Sub algorithm          (b)  Recursion   
(c) Polish notation      (d)  Traversal algorithm 
36. Find the complexity of the following code
main( )
{
    int x=0,y=1,z=2; 
x = y + z;
     for(i=0;i<n−1;i++)
{
          for (j=0;j<n;j++)
          {
                     x= y + z;
   }
    }
}
(a) O(n)  (b) O(n2)
(c) O(nlogn)               (d) O(2n)
37. What does a run-time analysis usually count?
(a) The number of arithmetic and other operations required for the program to run
(b) The number of megabytes required for the program to run
(c) The number of seconds required for the program to run
(d) The number of seconds plus the number of megabytes
38. Which of these is the correct big-O expression for 1+2+3+...+n?
(a) O(log n) (b) O(n)
(c) O(n log n) (d) O(n²)
39. Which of the following formulas in big-O notation best represent the expression n²+35n+6?
(a) O(log n) (b) O(n)
(c) O(n log n) (d) O(n²)
40. Answer true or false for this statement: For all possible inputs, a linear algorithm to solve a
problem must perform faster than a quadratic algorithm to solve the same problem.
(a) True (b) False
41. Answer true or false for this statement: An algorithm with worst case time behavior of 3n takes
at least 30 operations for every input of size n=10.
(a) True (b) False
42. What term is used to describe an O(n) algorithm?
(a) Constant (b) Linear
(c) Logarithmic (d) Quadratic
43. Here is some code for an integer variable n:
while(n>0)
{
n = n/10; // Use integer division
}
What is the worst-case time analysis for the above loop?
(a) O(1) (b) O(log n)
(c) O(n) (d) O(n²)
44. Which of the following case does not exist in complexity theory?
(a) Best case (b) Worst case
(c) Average case (d) Null case
45. The Worst case occur in linear search algorithm when 
(a) item is somewhere in the middle of the array
(b) item is not in the array at all
(c) item is the last element in the array
(d) item is the last element in the array or is not there at all
46. The Average case occur in linear search algorithm
(a) when item is somewhere in the middle of the array 
(b) when item is not in the array at all
(c) when item is the last element in the array
(d) when item is the last element in the array or is not there at all
47. The complexity of the average case of an algorithm is 
(a) much more complicated to analyze than that of worst case
(b) much more simpler to analyze than that of worst case
(c) sometimes more complicated and some other times simpler than that of worst case 
(d) none or above
48. Which of the following data structure is linear type?
(a) Strings (b) Lists
(c) Queues (d) All of above
49. In, search start at the beginning of the list and check every element in the list.
(a) Linear search (b) Binary search
(c) Both (a) and (b) (d) None of the above
50. State True or False.
(i) Binary search is used for searching in a sorted array.
(ii) The time complexity of binary search is O(n).
(a) False, True (b) False, False
(c) True, True (d) True, False
51. Which of the following is not the part of ADT description?
(a) Data (b) Implementations
(c) Both (a) and (b) (d) None of the above
52. A mathematical-model with a collection of operations defined on that model is called
(a) Data Structure (b) Abstract Data Type
(c) Primitive Data Type (d) Algorithm
53. O(N) (linear time) is better than O(1) constant time.
(a) True (b) False
54. Time complexities of three algorithms are given. Which should execute the slowest for large
values of N?
(a) O(N 1/ 2) (b) O(N)
(c) O(log 2N) (d) O(1)
55. What is the running time of the following code fragment?
int f(int n)
{
int s=0
while(n>1)
{
n=n/2;
s++;
}
return s;
}
(a) O(N2) (b) O(N)
(c) O(log 2 N) (d) O(1)
56. Consider the following function f:
int f(int n)
{
int s = 0;
while(n>1)
{
n = n/2;
s++;
}
return s;
}
What is the asymptotic complexity of f in terms of n? (Pick the smallest correct answer)
(a) O(n) (b) O(log2n)
(c) O(nlog2n) (d) O(n2)
57. ADT is 
(a) set of data values (b) set of operations
(c) both (a) and (b) (d) none of the above
58. Entity is 
(a) something which has attributes
(b) data items
(c) data values
(d) none of the above
59. Algorithm complexity is specified using notation 
(a) Big O (b) 
(c)  (d) all of the above
60. Field represents 
(a) attribute of data (b) attribute of entity
(c) attribute of data structure (d) attribute of ADT
61. Which of the following is not linear data structure?
(a) Array (b) Stack
(c) Queue (d) Tree
62. Which one of the following is not non−linear data structure?
(a) Tree (b) Graph
(c) Binary search tree (d) Priority queue
63. The variables declared inside a function body are called 
(a) local variables (b) global variables
(c) parameters (d) arguments
64. The variables which can be accessed by all the functions in the program are called 
(a) local variables (b) global variables
(c) parameters (d) arguments
65. Which logic is used to select one out of several alternatives?
(a) Sequence logic (b) Iteration logic
(c) Selection logic (d) Alternate logic
66. An independent algorithmic module is called 
(a) procedure (b) program
(c) logic (d) none of the above
67. The worst case time complexity of linear search is 
(a) O(1) (b) O(n)
2
(c) O(n ) (d) O(log2n)
68. The best case time complexity of linear search is 
(a) O(1) (b) O(n)
2
(c) O(n ) (d) O(log2n)
69. The worst case time complexity of binary search is 
(a) O(1) (b) O(n)
2
(c) O(n ) (d) O(log2n)
70. The best case time complexity of binary search is 
(a) O(1) (b) O(n)
2
(c) O(n ) (d) O(log2n)
71. The number of comparisons required in bubble sort in worst case is 
(a) n(n − 1)/2 (b) n(n + 1)/2
2
(c) n (d) n
72. The number of comparisons required in bubble sort in best case is 
(a) n (n − 1) (b) n (n + 1)/2
(c) n2 (d) n
73. Term data structure refers to  and interrelationship between them.
(a) organisation of data element
(b) programming
(c) coding standard
(d) algorithm
74. Data is nothing but 
(a) bunch of information
(b) piece of information
(c) programming statement
(d) algorithm
75. Data structure may be of  types.
(a) 2 (b) 3
(c) 1 (d) 4
76. Single and non-decomposite data is called 
(a) atomic data (b) composite data
(c) textual data (d) numeric data
77. Atomic data is also called 
(a) textual data (b) dynamic data
(c) scalar data (d) vector data
78. Data that can be broken down into small pieces and each sub−field having some meaning is
called 
(a) textual data (b) atomic data
(c) dynamic data (d) composite data
79. Mathematical model that can have a set of operations that can be performed on that model is
called as 
(a) primitive data type (b) abstract data type
(c) composite data type (d) data structure
80. Abstract data type is representation of data structure in memory.
(a) True (b) False
81. Variable which can be accessed by all modules of program is called 
(a) global variable (b) local variable
(c) static variable (d) external variable
82. In which data structure we can delete/insert element easily?
(a) Array (b) Linked list
(c) Tree (d) Priority queue
83. In linear data structure each and every element has unique successor and predecessor excluding
first and last element.
(a) True (b) False
84. Array is an example of non-linear data structure.
(a) True (b) False
85. In non−linear data structure data contains hierarchical and network relationship between
elements.
(a) True (b) False
86. Which of the following is non-linear data structure?
(a) Array (b) Linked list
(c) Tree (d) All the above
87. If a[ ] is an array of integers, then the value of &a[i] is same as 
(a) a+i (b) a + size of (int)
(c) a + size of (i) (d) a[i]
88. Size of array need not be specified when 
(a) initialization is part of definition (b) array size is small
(c) array size is large (d) all the above
89. Which of the following is illegal array definition in C.
(a) int a[ ]; (b) int a[110];
(c) int a(5); (d) all the above
90. What will be output of the following program?
int a, b, c;
void add( );
void main( );
{
a=10; b=20;
add( );
printf(“%d”, c);
}
void add( )
{
int c;
c = a + b;
}
(a) Garbage (b) 0
(c) 30 (d) 1020
91. What will be output of the following program?
int a, b, c;
void add( );
void main( )
{
a=10; b=20;
add( );
printf(“%d”, c);
}
void add( )
{
c=a+b;
}
(a) 30 (b) 0
(c) Garbage (d) 1020
92. Scope of local variables is 
(a) entire program
(b) all functions
(c) limited to block in which they are declared
(d) limited to functions which are defined after the declaration
93. Elements of array can be 
(a) accessed randomly
(b) must be accessed sequentially
(c) must be accessed through pointer
(d) must be accessed through address
94. The first part of an algorithm tells the  of the algorithm.
(a) logic (b) process
(c) purpose (d) steps
95. Each step of an algorithm may contain its  in brackets.
(a) purpose (b) functions
(c) steps (d) comments
96. The term  will be used for an independent algorithmic module which solves a particular
problem.
(a) program (b) logic
(c) procedure (d) name
97.  logic employs a number of conditions which lead to a selection of one out of several
alternative modules.
(a) Selection (b) Sequential
(c) Iteration (d) Procedural
98. A structure is of the form:
if condition, then:
[Module A]
else
[Module B]
[End of structures]
What is this structure?
(a) Multiple alternative (b) Double alternative
(c) Single alternative (d) None of the above
99.  loop uses a condition to control the loop.
(a) Repeat−for (b) Repeat
(c) Continue (d) Repeat−while
100. In complexity theory,  case refers to the expected value of f(n).
(a) average (b) best
(c) worst (d) good
101. O(n2) is the complexity of which algorithm?
(a) Binary search (b) Linear search
(c) Both (a) and (b) (d) Bubble sort
102. The  notation is used when the function g(n) defines a lower bound for the function f(n).
(a) Omega (b) Big O
(c) Theta (d) Little Oh
103. Each program module contains its own list of variables called 
(a) global (b) local
(c) search (d) binary
104.  function of C is used to allocate a block of memory.
(a) malloc( ) (b) calloc( )
(c) free (d) realloc( )
105. Variables that can be accessed by all program modules are called  variables.
(a) global (b) local
(c) search (d) non-local
106.  refers to a single unit of values.
(a) Group item (b) Data item
(c) Elementary item (d) Basic item
107. A is something that has certain attributes or properties which may be assigned values.
(a) field (b) record
(c) entity (d) file
108. is the collection of records of the entities in a given entity set.
(a) Field (b) Record
(c) Entity (d) File
109. The value in a field uniquelydetermines the record in a file.
(a) primary key (b) secondary key
(c) key (d) pointer
110. In length records, file recordsmay contain different lengths.
(a) fixed (b) primary
(c) variable (d) entity
111.  is the logical or mathematical model of a particular organization of data.
(a) Structure (b) Variable
(c) Function (d) Data Structure
112. Which of the following is not a primitive data structure?
(a) Boolean (b) Integer
(c) Arrays (d) Character
113. Which of the following is a non-linear data structure?
(a) Array (b) Linked List
(c) Stack (d) Graph
114.  is also called last-in-first-out(LIFO) system.
(a) Queue (b) Stack
(c) Graph (d) Tree
115. is also called first-in first-out (FIFO) system.
(a) Tree (b) Stack
(c) Queue (d) Graph
116. Which of the following operations accesses each record exactly once so that certain items may
be processed?
(a) Inserting (b) Deleting
(c) Traversing (d) Searching
117. is a data structure that contains a relationship between a pair of elements, which is not
necessarily hierarchical in nature.
(a) Tree (b) Graph
(c) Array (d) String
118. involves arranging the records in a logical order.
(a) Merging (b) Sorting
(c) Traversing (d) Searching
119. is a set of data values and associated operations that are specified accurately, independent
of any particular implementation.
(a) Stack (b) Tree
(c) Abstract Data Type (d) Graph
120. Which of the following operations combine records in two different sortedfiles into a single
sorted file?
(a) Inserting (b) Sorting
(c) Searching (d) Merging
121. Array is used to represent 
(a) a list of data items of integer data type
(b) a list of data items of real data type
(c) a list of data items of different data type
(d) a list of data items of same data type
122. Array name is
(a) an array variable (b) a keyword
(c) a common name shared by all elements (d) not used in a program
123. One-dimensional array is known as
(a) vector (b) table
(c) matrix (d) any array of an integers
124. The array elements are represented by
(a) index values (b) subscripted variables
(c) array name (d) size of an array
125. Array elements occupy
(a) subsequent memory locations
(b) random location for each element
(c) varying length of memory locations for each element
(d) no space in memory
126. Array subscripts in C always start at 
(a) –1 (b) 0 (c) 1 (d) any value
127. Maximum number of elements in the array declaration int x[10]; is
(a) 9 (b) 10 (c) 11 (d) undefined
128. The elements of the following array x are 
float x[5];
(a) x[0], x[1], x[2], x[3], x[4] (b) x[1], x[2], x[3], x[4], x[5]
(c) x(0),x(1),x(2),x(3), x(4) (d) x(1),x(2),x(3),x(4), x(5)
129. Array declaration
(a) requires the number of elements to be specified
(b) does not require the number of elements to be specified
(c) assumes default size as 0
(d) is not necessary
130. To initialize a 5 element array all having value 1 is given by 
(a) int num [5] = (1);
(b) int sum [4] = (1, 1, 1, 1, 1);
(c) int sum [ ] = {1, 1, 1, 1, 1};
(d) int num [ ] = (1);
131. To initialize a 5 element array all having value 0 is given by 
(a) int num [5] = {0};
(b) int num [5] = {0, 0, 0, 0, 0};
(c) options (a) and (b)
(d) Int Num [5] = (1);
132. If the size of an array is less than the number of initializers 
(a) the extra values are neglected (b) it is an error
(c) the size is automatically adjusted (d) the size is neglected
133. Missing elements of partly initialized arrays, are
(a) set to zero (b) set to one (c) not defined (d) invalid
134. The declaration of array main( ) {int a [10]; −−−}
(a) reserves the space required for 11 elements
(b) reserves space for 9 elements
(c) does not initialize any element
(d) initializes the values of all elements to 0
135. The value within the [ ] in an array declaration specifies 
(a) subscript value (b) index value
(c) size of an array (d) value of the array element
136. The value within the [ ] in an array variable specifies 
(a) suscript value (b) size of the array
(c) value of the array element (d) array bound
137. When should an array be used?
(a) When we need to hold variable constants.
(b) When we need to hold data of the same type
(c) When we need to obtain automatic memory cleanup functionality
(d) When we need to hold data of different types.
138. main ( )
{
int a [100], i;
for(i=1;i<=100;++i) {. . . ;}
}
(a) The above loop statement is incorrect since the last valid subscript of a is 99
(b) The above loop statement is incorrect since i is not intialized to 0.
(c) The above loop statement is correctfor processing elements of array
(d) The above loop statement is incorrect since i is pre-incremented.
139. main( )
{
const in size = 5;
int i, n, line [size];
for(i=0;i<n;i++)
{
line[i] = i;
}
}
What will happen when the sample code fragment above is executed?
(a) The array will be initialised with the numbers 0 through 39
(b) The code will not compile
(c) The code will compile with warnings
(d) The code will compile, but not link
140. What is the output of the following code?
int cap (int);
main( )
{
int n; n = cap (6);
printf ("%d”,n);
}
int cap (int n)
{
if (n <= 1) return 1;
else return (cap (n – 3) + cap (n – 1);
}
(a) 7 (b) 8 (c) 9 (d) 10
141. The program execution starts from
(a) the function which is first defined (b) main( ) function
(c) the function which is last defined (d) the function other than main( )
142. How many main( ) functions can be defined in a C program?
(a) 1 (b) 2
(c) 3 (d) any number of times
143. A function with no action
(a) is an invalid function
(b) produces syntax error
(c) is allowed and is known as dummy function
(d) returns zero
144. Parameters are used
(a) to return values from the called function
(b) to send values from the calling function
(c) options a and b
(d) to specify the data type of the return value
145. Identify the correct statement.
(a) A function can be defined more than once in a program.
(b) Function definition cannot appear in any order.
(c) Functions cannot be distributed in many files.
(d) One function cannot be defined within another function definition.
146. The default return data type in function definition is
(a) void (b) int (c) float (d) char
147. The parameters in a function call are
(a) actual parameters (b) formal parameters
(c) dummy parameters (d) optional
148. The parameters in a function definition are
(a) actual parameters (b) formal parameters
(c) dummy parameters (d) optional
149. The parameters passing mechanism used in C is
(a) call by reference (b) call by name
(c) call by value (d) options a and b
150. Recursive call results when
(a) a function calls itself
(b) a function 1 calls another function, which in turn calls the function 1
(c) Options a and b
(d) a function calls another function
151. What function must all C programs have?
(a) start( ) (b) main( ) (c) return( ) (d) exist( )
152. In C, which of the following statement(s) is (are) TRUE about the way the arguments are passed?
1. The order of evaluation of arguments is compiler dependant.
2. Arguments are passed by reference.
(a) both options 1 and 2 (b) only option 1
(c) only option 2 (d) neither option 1 nor 2
153. Which of the following statements in C is/are TRUE ?
1. Two functions can have the same name in a single program.
2. Function calls can be recursive.
(a) both options 1 and 2 (b) only option 1
(c) only option 2 (d) neither option 1 nor 2
154. long factorial (long x)
{
????
return x *factorial (x – 1);
}
What would you replace the ???? with, to make the function shown above, return the correct
answer?
(a) if (x==0) return 0; (b) if (x==0) return 1;
(c) if (x<=1) return 1; (d) return 1;
155. void func(int x)
{
if (x>0) func (– – x);
printf ("%d", x);
}
int main()
{
func (5);
return 0;
}
What will the above sample code produce when executed?
(a) 0, 1, 2, 3, 4, 5 (b) 0, 0, 1, 2, 3, 4 (c) 4, 3, 2, 1, 0 (d) 5, 4, 3, 2, 1, 0,
156. When a function is recursively called, all automatic variables are
(a) stored in stack (b) stored in quence
(c) stored in array (d) stored in linked list
157. main( )
{
int n = 10;
fun (n);
}
int fun (int n)
{
int i;
for(i=0;i<=n;i++)
fun (n – i);
printf ("Hello");
}
How many times is the printf statement executed for n = 10?
(a) 1 (b) Infinity (c) Zero (d) 10
158. main( )
{}
int a;
f1 ( ) { }
f2 ( ) { }
To which of the above functions, is int a available for?
(a) all of them (b) only f2 (c) only f1 (d) f1 and f2 only
159. What will be result of the following program?
main( )
{
void f (int, int);
int i = 10;
f (i, i++)
}
void f (int i, int j)
{
if (i>50)
return;
i + = j;
f (i, j);
printf ("%d,", i);
}
(a) 85, 53, 32, 21 (b) 10, 11, 21, 32, 53
(c) 32, 21, 11, 10 (d) none of the above
160. What is the output of the following code?
main( )
{
printf("%d\n", sum (5));
}
int sum(int n)
{
if (n < 1) return n;
else return (n + sum (n – 1) );
}
(a) 10 (b) 16 (c) 14 (d) 15
161. What is the output generated by the following program?
int sq(int);
#include<stdio.h>
main( )
{
int i, x ;
for(i=1;i<=5;i++)
{
x = sq (i);
printf("%d", x);
}
}
int sq (int x)
{
return x * x ;
}
(a) 1234567 (b) 2516941 (c) 9162514 (d) 1491625
162. What is the output of the following code?
int n = –24 ;
main( )
{
printd(n) ;
}
printd(int n)
{
if(n<0)
{
printf(" – ");
n=–n;
}
if (n%10) printf("%d", n);
else printf("%d", n/10) ;
printf("%d", n) ;
}
(a) –24 (b) 24 (c) –2424 (d) –224
163. 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) None of the above
164. The following program
main( )
{ printf(“Hello”);
main( ); }
(a) is illegal (b) keeps on printing “Hello”
(c) prints “Hello” once (d) none of the above
165. 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 programming across programs
(d) all the above
166. Pick the correct statements.
(a) The body of a function may have many return statements
(b) A function can return only one value to the calling environment
(c) If return statement is omitted, then the function does its job but returns no value to the
calling environment
(d) All the above
167. max is a function that returns the larger of the two integers, given as arguments. Which of the
following statements finds the largest of three given numbers?
(a) max(max(a, b), max(a, c)) (b) max(a, max(a, c))
(c) max(max(a, b), max(b, c)) (d) max(b, max(a, c))
168. void can be used 
(a) as a data type of a function that returns nothing to its calling environment
(b) inside the brackets of a function that does not need any argument
(c) both (a) and (b)
(d) none of the above

169. The following program


main( )
{ int a=4;
change(a);
printf(“%d”, a);
}
change (int a)
{
printf(“%d”, ++a);
}
Outputs:
(a) 55 (b) 45
(c) 54 (d) 44
170. The following program
main( )
{
inc( ); inc( ); inc( );
}
inc( )
{
static int x;
printf(“%d”, ++x);
}
(a) prints 012
(b) prints 123
(c) prints 3 consecutive, but unpredictable numbers
(d) prints 111
171. The average successful search time for sequential search on ‘n’ terms is 
(a) n/2 (b) (n−1)/2
(c) (n+1)/2 (d) log (n) + 1
172. The concept of order (Big O) is important because 
(a) it can be used to decide the best algorithm that solves a given problem
(b) it determines the maximum size of a problem that can be solved in a given system, in a
given amount of time
(c) it is the lower bound of the growth rate of the algorithm
(d) all the above

1. (d) 2. (b) 3. (c) 4. (d) 5. (a) 6. (a) 7. (d) 8. (b) 9. (a) 10. (b)
11. (b) 12. (b) 13. (a) 14. (c) 15. (c) 16. (a) 17. (b) 18. (b) 19. (a) 20. (d)
21. (d) 22. (d) 23. (a) 24. (b) 25. (d) 26. (b) 27. (c) 28. (b) 29. (a) 30. (c)
31. (d) 32. (a) 33. (b) 34. (a) 35. (b) 36. (b) 37. (a) 38. (d) 39. (d) 40. (a)
41. (a) 42. (b) 43. (b) 44. (d) 45. (d) 46. (a) 47. (a) 48. (d) 49. (a) 50. (d)
51. (c) 52. (b) 53. (b) 54. (b) 55. (a) 56. (b) 57. (c) 58. (a) 59. (d) 60. (b)
61. (d) 62. (d) 63. (a) 64. (b) 65. (c) 66. (a) 67. (b) 68. (a) 69. (d) 70. (a)
71. (a) 72. (d) 73. (a) 74. (b) 75. (a) 76. (a) 77. (c) 78. (d) 79. (b) 80. (b)
81. (a) 82. (b) 83. (a) 84. (b) 85. (a) 86. (c) 87. (a) 88. (a) 89. (d) 90. (b)
91. (a) 92. (c) 93. (a) 94. (c) 95. (d) 96. (c) 97. (a) 98. (b) 99. (d) 100. (a)
101. (c) 102. (a) 103. (b) 104. (a) 105. (a) 106. (b) 107. (c) 108. (d) 109. (a) 110. (a)
111. (d) 112. (c) 113. (d) 114. (b) 115. (c) 116. (c) 117. (b) 118. (b) 119. (c) 120. (d)
121. (d) 122. (c) 123. (a) 124. (b) 125. (a) 126. (b) 127. (b) 128. (a) 129. (a) 130. (c)
131. (c) 132. (b) 133. (a) 134. (c) 135. (c) 136. (a) 137. (b) 138. (a) 139. (c) 140. (c)
141. (b) 142. (a) 143. (c) 144. (b) 145. (d) 146. (b) 147. (a) 148. (b) 149. (c) 150. (a)
151. (b) 152. (b) 153. (c) 154. (b) 155. (b) 156. (a) 157. (c) 158. (a) 159. (d) 160. (d)
161. (d) 162. (c) 163. (a) 164. (b) 165. (d) 166. (d) 167. (d) 168. (c) 169. (c) 170. (b)
171. (c) 172. (d)

You might also like