1. Which of the following symbols is used used to denote a pre-processor pre-processor statement? statement?
2.
A) !
B) #
C) ~
D) ;
The preprocessor preprocesso r in C language is used for A) processing the function calls B) processing input and output statements C) processing the preprocessor directives D) processing all the statements in program
3.
The declaration declaratio n int a[10]; In c Language means A)
the value 10 is assigned to variable ‘a’
B)
it is character array which can store 10 characters
C)
it is integer array which can store 10 integer integer values in an array
D)
both ‘b’ and ‘c’
4. struct data type type in C language language is used for A)
storing group of different data types
B)
storing group of same data type
C)
storing only one data type
D)
all of the above
5. Symbolic constants can be defined using a_________ A)
# define directive B)
const keyword
C)
symbolic notation D)
None of these
6. A string is terminated by a _____________ character, which is written as ____________ A)
blank, ‘’
B) new line, \n
C)
null, ‘\0’
D) string, %s
7. Which expression reference to the 4th 4th element of an array A)
num[4];
B) int a(4);
C)
num(0-4);
D)
num[3];
8. Which of the following statements is true? A)
The array int num[27] has twenty six element
B)
The expression num [0] designates the first element in the array.
C)
It is necessary to initialize initialize the array at the the time time of declaration.
D)
The expression num[27] designates the twenty sixth element in the array
9. The expressions written in the ` for ` loop, are separated using a _____________. A)
colon
B) comma
C) semicolon
D) hyphen
10. malloc() function used in dynamic memory allocation is available in which header file? A)
stdio.h
B)
stdlib.h
C) conio.h
D)
mem.h
D)
;
11. Indexing of array starts with___________ A)
1
B) 2
C) 0
D)
any
12. Which symbol is used as a ` statement terminator ` in ` C ` ? A)
!
B) #
C) ~
13. Which among the following is a unconditional uncondition al control structure ? A)
do-while
B) if-else
C) goto
D) for
14. A "do... while " loop terminates, when the expression written in ` while ` returns _______ A)
1
B) 0
C) –1
D) NULL
15. Which of the the following is a keyword keyword used for denoting denoting a storage storage class? A)
printf
B) external
C) auto
D) scanf
16. Which amongst the following is not a structured data type? A)
Array
B) void
C) structure
D) union
17. Minimum number of temperory variables needed to exchange the contents of two variables variable s is A)
1
B) 2
C) 3
D) 0
18. The body body of a ` WHILE ` Loop Loop has
19.
A)
one statement only
B) atleast two statements
C)
one or more statements statements
D) None of above.
Determine which of the following is invalid numeric constant. A)
0.5
B) 27,822
C) 12345678
D) 0XBCFDAL
20. Which is is not conditional and unconditional unconditional branching branching ? A)
if
B) switch
C) break
21. Which of the following statement is correct ? A)
C provides no input-output input-ou tput feature
B)
C provides no file access feature
C)
C provides no feature to manipulate composite objects
D)
All of above
22. The following statement prints("%f",9/5); prints("%f",9/ 5); prints
D) include
B)
The expression num [0] designates the first element in the array.
C)
It is necessary to initialize initialize the array at the the time time of declaration.
D)
The expression num[27] designates the twenty sixth element in the array
9. The expressions written in the ` for ` loop, are separated using a _____________. A)
colon
B) comma
C) semicolon
D) hyphen
10. malloc() function used in dynamic memory allocation is available in which header file? A)
stdio.h
B)
stdlib.h
C) conio.h
D)
mem.h
D)
;
11. Indexing of array starts with___________ A)
1
B) 2
C) 0
D)
any
12. Which symbol is used as a ` statement terminator ` in ` C ` ? A)
!
B) #
C) ~
13. Which among the following is a unconditional uncondition al control structure ? A)
do-while
B) if-else
C) goto
D) for
14. A "do... while " loop terminates, when the expression written in ` while ` returns _______ A)
1
B) 0
C) –1
D) NULL
15. Which of the the following is a keyword keyword used for denoting denoting a storage storage class? A)
printf
B) external
C) auto
D) scanf
16. Which amongst the following is not a structured data type? A)
Array
B) void
C) structure
D) union
17. Minimum number of temperory variables needed to exchange the contents of two variables variable s is A)
1
B) 2
C) 3
D) 0
18. The body body of a ` WHILE ` Loop Loop has
19.
A)
one statement only
B) atleast two statements
C)
one or more statements statements
D) None of above.
Determine which of the following is invalid numeric constant. A)
0.5
B) 27,822
C) 12345678
D) 0XBCFDAL
20. Which is is not conditional and unconditional unconditional branching branching ? A)
if
B) switch
C) break
21. Which of the following statement is correct ? A)
C provides no input-output input-ou tput feature
B)
C provides no file access feature
C)
C provides no feature to manipulate composite objects
D)
All of above
22. The following statement prints("%f",9/5); prints("%f",9/ 5); prints
D) include
A)
1.8
B) 1
C) 2
D) none of these
23. which of the following is not a logical operator? A)
&
B) &&
C) ||
D. !
24. How do printf() ` s format specifiers %e and %f differ in their treatment of floating-point numbers? A)
%e always displays an argument of type double in engineering engineering notation; notation; %f always always displays displays
an argument of type double in decimal notation B)
%e expects a corresponding argument of type double; %f expects a corresponding correspondi ng
argument of type float. C)
%e displays a double in in engineering engineering notation notation if the the number is very small small or very very large.
Otherwise, Otherwise, it behaves like %f and displays the number in decimal notation. D)
%e displays an argument of type double with trailing zeros; %f never displays trailing zeros.
25. Which of the following is not a character classification in the ‘C’ language? A)
alphabets
B) characters
C)
digits
D) graphical
26. Consider following statments I] An array is variable which can store multiple elements of similar type.II] Structure contains similar data types together. A)
I is correct
B) II is correct
C)
I & II are correctD) None of above.
27. In "C" program, constant is defined A)
before main
B) after main
C)
anywhwre
D) none of above
28. A character variable can at a time store maximum _____________. A)
1 Byte
B) 4 Bytes
C) 8 Bytes
D) 16 Bytes
29. What is the meaning of ‘while (1)’? A)
Execution of loop only once
B) Execution of loop at least once
C)
Infinite Loop
D) No execution of the loop
30. Which of the the following is not an integer integer constant constant in ` C ` language? language? A) –320
B) –14.05
C) 45
D) 1456
31. One of the following is not a character character constant in ` C ` language. language. Identify Identify it. A)
''
B) 'bb'
C) d
D) '?'
C) switch(choice) switch(choi ce)
D) for
32. Which one is not keyword? A)
else
B) while
33. Find the correct form of ` nested if ` A)
if(if(condition)) if(if(condition)) do this;
B)
else(if(condition) do this;
C)
if(condition) { if(condition) do this; }
D)
if&&if(condition)
34. Which symbol is used to separate multiple initialization in the ‘for’ loop? A)
&&
B) ,
C)
;
D) None of the above
35. The keyword ………….. allows to take the control to the beginning of the loop, by passing the statements inside the loop, which have not yet been executed. A)
goto
B)
for
C) continue
D) case
36. Which of the following loop is not used in ` C ` language? A)
'for' loop
B) 'if...else'
C)
'Repeat...until' loop
D) 'do..while' loop
37. When the keyword ________ is encountered inside any ‘C’ loop, control automatically passes to the first statement after the loop. A) 38.
goto
B) break
C) default
D) continue
Which of the following ‘for’ statements is wrong?
A)
for(i=0, j=1;i<5;i++) B)
for(i=0;i<5;i++);
C)
for(i=0;i<5;i++);D) for(;i>7;)
39. How many ` ; ` (semicolon) are included in ` for ` statement (or loop)? A)
0
B) 1
C) 2
D) 3
40. The _____statement allows the programmer to take the control to the beginning of the loop, bypassing the statement inside the loop which has not yet been executed. A)
while
B) continue
C) go to
D) if
41. Which of the following is a Scalar Data type? A)
Float
B) Union
C) Array
D) Pointer
42. The _______loop allows programmer to specify three things about a loop in single line. A)
for
B) while
C) goto
D) switch
43. For using character function, we must include the header file _____in the program. A)
string.h
B) stdio.h
C) ctype.h
D) math.h
44. Which one of the following is a true statement about pointers? A)
They are always 32-bit values.
B)
For efficiency, pointer values are always stored in machine registers.
C)
With the exception of generic pointers, similarly typed pointers may be subtracted from
each other. D)
A pointer to one type may not be cast to a pointer to any other type.
45. Which one of the following variable names is not valid?
A)
go_cart
B) go4it
C) 4season
D) run4
46. Which of the following is not a floating point constant in ` C ` language? A)
45.6
B) -31.8
C)
pi
D) 40
47. The expression ` x != y ` is true if A)
x is equal to y.
B) x is not equal to y.
C)
x is less than or equal to y
D) x is greater than or equal to y.
48. Which of the following is not a valid indentifier in ` C ` language? A)
A3
B) B.A_4
C) if
D) IF
49. Which of the following statements about the ` switch ` statement is false? A)
No two case labels can have the same value
B)
The switch control expression must be of 'character' type
C)
The case-labled constant can be a constant or a variable
D)
Two case labels can be associated with the same statement series
50. A two way selection is implemented in the program, by using __________ statement. A)
case
B) else..if
C) switch
D) if..else
51. Header files in C contains A)
Compiler commands
B)
Library functions
C)
Header information of C programs
D)
Operators for files
52. Which header file contains strlen() function? A)
stdio.h
B) conio.h
C) string.h
D) math.h
53. Which statements is used to take the control to the beginning of the loop? A)
exit
B) break
C) continue
D) no of these
54. Which of the following gives the memory address of a variable pointed to by pointer named as ` p`? A)
p;
B) *p;
C) &p;
D) addressA);
55. An integer constant in C must have______ A)
at least one digit
B)
at least one decimal point
C)
A comma along with digits
D)
Digits separated by commas
56. A ‘do...while’ loop is useful when we want that statement within the loop must be executed_________. A)
only once
C)
more than once
B) at least once D)
none of above.
57. Which of the following gives the value stored in a pointer named as ` a ` ? A)
a;
B) valA);
C) *a;
D) &a;
58. The real constant in C can be expressed in which of the following forms? A)
Fractional form only
B)
exponential form only
C)
ASCII form only
D)
both fractional and exponential forms
59. The statement char ch= ‘Z’ would store what in variable named ` ch ` ___________ A)
the character Z
B)
ASCII value of Z
C)
Z along with single inverted commas
D)
both (1) & (2).
60. The maximum value that an integer constant can have is_________ A)
-32767
B) 32767
C)
1.70E+38
D) -1.70E+38
61. Which of the following is not a valid character constant? A)
‘thank you’
B) ‘enter values of P,N,R’
C)
’23.56E-03’
D)
all the above
62. If ` a ` is an integer variable, a=5/2; will initialize the variable ` a ` with the value____ A)
2.5
B) 3
C) 2
D) 0
63. Which of the following is the correct output for the program given below? #include void main() { int i=1; if(!i) printf("Recursive calls are painful\n"); else { i=0; printf("Recursive calls are challenging A)
Recursive calls are challenging. Recursive calls are painful.
B)
Recursive calls are painful. Recursive calls are challenging.
C)
Recursive calls are the challenging.
D)
The code prints Recursive calls are challenging. Recursive calls are challenging (infinitely?.)
64. In ` C ` a variable name can not contain______ A)
blank spaces
B) hyphen
C)
decimal point
D) all the above
65. Which of the following symbol is used to denote a pre-processor statement? A)
!
B) #
C) ~
D) ;
66. Which of the following gives the memory address of an int eger variable ‘a’ ? A)
*a;
B) a;
C) &a;
D) addressA);
67. Which of the following is the proper declaration of an integer pointer? A)
int x;
B) int &x;
C) int x*;
D) int *x;
68. The _______symbol is used to denote any function of an input/output device in the program flowchart. A)
Flowlines
B) Processing
C) parallelogram
D) Terminal.
69. A ______Symbol is used in a flowchart to represent arithmetic and data movement instructions. A)
Flowlines
B) Processing
C)
Input/Output
D) Terminal.
70. The ________with arrowheads are used to indicate the flow of an operation, that is, the exact Sequence in which the instructions are to be executed. A)
Flowlines
B) Processing
C) Decision
D) Terminal.
71. Which of the following shows the correct hierarchy of arithmetic operators in ‘C’ ?
72.
A)
**,* or / ,- or +B) **, * or /, + or -
C)
**, /, *, +, -
D) . / or *, - or +
The keyword _________is followed by an integer or character constant. A)
switch
B) case
C) for
D) void
73. What is the maximum size of a double variable? A)
1Byte
B) 4 Bytes
C) 8 Bytes
D) 16 Bytes
74. The size of a string variable is______________. A)
1 Byte
B) 4 Bytes
C)
Size of String array D)
None of these
75. The ______ logic is used to produce loops in program , depending on some condition. A)
Iteration logic
C)
Sequence logic
B) Selection logic D)
Decision logic
76. What is meaning of a ‘ * ` symbol when used before a variable ?
77.
A)
‘address of a variable
B) location of a variable
C)
space of a variable D) value at an address
Which escape character can be used to begin a new line in ` C ` ? A)
\a
B) \b
C) \m
D) \n
78. Which of the following operators has the 2nd highest priority? A)
=
B) * / %
C) + -
D) ||
79. A character constant should be enclosed within a pair of ___ A)
Single quotes
B) Double quotes
C)
Both a and b
D) None of these
80. A string constant should be enclosed within a pair of _____ A)
Single quotes
B) Double quotes
C)
Both a and b
D)
None of these
81. Which of the following is an invalid character constant? A)
')'
B) '$'
C) 'a'
D) 'abc'
82. The maximum length of a variable in ` C ` programming language is __________ A)
8
B) 16
C) 32
D) 64
83. What is meaning of a ‘&’ symbol when used before a variable? A)
address of a variable
B) value of a variable
C)
space of a variable D) name of a variable
84. To return control back to the calling program which keyword is used.? A)
void
B)
return
C)
back
D)
None
85. Which operators are useful in pointer operators? A)
#
B) #
C)
*and &
D) None
86. If int s[5] is one dimentional array of integers which of the following refers to third element in an array? A)
s[2]
B) s[3]
C) s+3
D) s+2
87. Following are the not looping statements. A)
if-then-else
B) do-while
C)
repeat-until
D) for loop
88. Structure is a collection of _______. A)
Different data types
B) Different constants.
C)
Different records. D) Same data types
89. Which of the following is not preprocessor directory? A)
#if
B) #elseif
C) #undef
D) #pragma
90. To receive the string "To my queen ", in an array char str[100],which of the following functions would you use? A)
scanf("%s",str);
B) gets(str)
C)
getche(str)
D) getchar(str)
91. Which operator is used to access the structure element? A)
*
B) .
C) ->
D) &
92. When we pass an array of a structure to a function it is passed by the____________ mechanism.
A)
Call by value
B) Call by reference
C)
Call by name
D) None
93. Unions are the _____________ A)
Inbuilt data types
B) Derived Data types
C)
Data types
D) None
94. An integer constant in C must have _________ . A)
Atleast one digit
B)
Atleast one decimal point
C)
A comma along with digits
D)
Digits seperated by commas
95. c = getchar(); What is the proper declaration for the variable c in the code ? A)
char *c;
B) unsigned int c;
C)
int c;
D) char c;
96. Scope of global variable is limited to A)
Entire program
B) with in function
C)
in a class
D) None
97. I/P devices are _________ . A)
monitor, keyboard, mouse
B) keyboard, mouse, scanner,
C)
Joystick, trackball, digitizer
D) Both B and C
98. Constant is ________. A)
Constant program code
B)
Constant variable declaration
C)
Both A and B
D)
Way to define variable that can not modified
99. Variable is _______ . A)
Identifier used to represent specific type of information
B)
Name associated with memory location
C)
Varying program statements
D)
Both A and B
100. Which of following operators in ‘C’ does not associate from the left to right? A)
+
B) ,
C) =
D) %
101. In an array declaration ‘int arr[12]’ t he word arr represents the _________. A)
Variable
B) string
C)
array variable
D) none of these.
102. What will happen if you put too many elements in an array when you initialize it? A)
nothing
B)
possible system malfunction
C)
error message from the compiler
D)
unused elements will be filled with 0’s or garbage
103. Which header file is essential for using strcmp() function? A)
string .h
B) strings.h
C) text.h
D) strcmp.h
104. What will happen if you assign a value to an element of an array whose subscript exceeds the size of array? A)
element will be set to zero.
B)
Nothing
C)
Other data may be overwritten
D)
Error message from compiler will occur
105. An Ampersand before the name of a variable denotes……………… A)
Actual Value
B) variable name
C)
Address
D) Data Type
106. When you pass an array as an argument to a function what actually gets passed? A)
address of array
B)
value of the elements of array
C)
address of first element of array
D)
number of elements of array
107. Can we use logical operators in ` if-else ` statement? A)
yes
B) no
C)
error
D) Both B and C
108. Which of following statements about ` for ` loop are correct? A)
Index value is retained outside the loop
B)
Index value can be changed from within the loop
C)
Goto can be jump, out of the loop
D)
All of above
109. Which of the following operator has the highest precedence? A)
*
B) ==
C) >=
D) +
110. Which of the following operator has the highest priority? A)
++
B) %
C) +
D) ||
111. The continue keyword cannot be used with A)
for
B) while
C) do
112. An union in C language denotes A)
memory location B)
C)
memory screen
memory store
113. Keywords are also called ___________ .
D) None of these
D) switch
A)
reserved words
B)
compiler words
C)
dictionary wordsD) programming words
114. Which of the following operator has the lowest priority? A)
++
B) %
C) +
D) ||
115. A ` C ` variable can not start with A)
an alphabet
B)
a number
C)
a special symbol other than underscore
D)
Both B) and C)
116. Which of the following is the correct syntax of for loop? A)
for (initialization, condition, inc/ dec )
B)
for (initialization, condition, inc/dec) { { ------; ------; ------; ------; } }
C)
for (initialization; condition; inc/dec)
D)
None of these { ------; ------; }
117. String constants should be enclosed between ______ . A)
Single quotes
B) Double quotes
C)
A or B
D) None of these
118. Which of the following is a correct way of representing a variable in A)
int 0ram;
B) float _calculate;
C)
int if;
D) int run#fast;
119. The _______ function is used to display the output on the screen. A)
scanf
B) printf
C)
getchar
D) clrscr
120. There are how many loop constructs in ` C ` language ? A)
3
B) 4
C) 1
121. An array name is ___________. A)
an array variable
B)
a keyword
C)
a common name shared by all of its elements
D)
not use in program
122. An array is used to represent ___________. A)
list of integer data item
B)
list of real data type
C)
list of different data type
D)
list of data item of same data type
D) 2
`C` ?
123. The ____________ format string is used for displaying floating point number with an exponent. A)
%d
B) %f
C) %e
D) %g
C) Three
D) None of these
124. How many loops are present in C? A)
One
B) Two
125. If a static array of integers is not initialized ,the elements will hold default value…….. A)
0
B) 1
C)
a integer number D) the charcter constant '\0'
126. What is a preprocessor directive? A)
It is a message from a compiler to the programmer
B)
It is a message from a compiler to the linker
C)
It is a message from a programmer to the preprocessor
D)
t is a message from a programmer to the microprocessor
127. The _________.enhances the versatility of the computer allowing it to perform a set of instructions repetedly. A)
compiler
B) loop l
C)
header files
D) statement
128. Which of the following is iterative control structures? A)
if statement
B) if-else statement
C)
do-while loop
D) goto statement
129. Which of the following control structures are used in an iteration logic _____________. A)
IF....THEN & IF...THEN...ELSE
B)
DO ..& WHILE
C)
DO..WHILE & REPEAT...UNTILL
D)
DO..WHILE & IF...ELSE
130. Explicit type conversion is known as ___________. A)
casting
B) conversion
C)
disjunction
D) separation
131. ` C ` variable can not start with___________ A) an alphabet B) a number C) a special symbol other than underscore D) both B) & C) above 132. In a while loop the parantheses after the ‘while’ contains a _________ A)
condition
B) statement
133. Keyword is ________ .
C) count
D) value
A)
Variable name
B) Constant word used in 'C'
C)
Reserve character of 'C'
D) All of above
134. ` If-else ` statement is used as ________ . A)
Decision control structure
C)
Repetition of code D)
B) Conditional statements Both B and C
135. I/P functions are _______ . A)
getchar(), puts(), gets()
B) getchar(), scanf(), gets()
C)
Both A and B
D) None of above
136. Which of the following statement is correct related to an if-else statement ? A)
If we use an if it is compulsory to use an else
B)
Every if-else can be replaced by ? : operator.
C)
Nested if-else is allowed.
D)
Only one if-else can be written.
137. C=getchar () is used for a _______________ operation. A)
Character input
C)
String input
B) character output D) string output
138. putcharD) function is used for a _____________ opearations. A)
Character input
C)
String input
B) character output D) string output
139. Which is the correct syntax of do while loop? A)
do { ------; ------;.)
B)
do{ ------; ------;)
C)
do { while (condition) ------; ------;}
D)
None of these
140. Syntax of while loop is _____. A)
while { (condition); ------; ------;
B)
while(condition) { ------; ------; }
C)
while {-----; ------; }(condition);
D)
none of these
141. Struct keyword is used to define … A)
array
B) string
C) union
D) structure
C) getch
D)
C) data type
D) None of these
142. . ... ... is standard output function A)
printf
B) scanf
clrscr
143. Which of the following is keyword A)
if
B) string
144. For string data type ... format specifier is used A)
%d
B) %c
C) %f
D) %s
145. When an ` if..else ` statement is included within an ` if ..else ` statement , it is known as a _________. A)
Next if statement B)another if statement
C)
combined if statement
D) Nested if statement
146. The ` *(&i) ` is stands for , A)
' value at address ' operator
B) ' address of ' operator
C)
both A&B
D) none of above
147. Which of the following is an iterative control structure? A)
If
B) if else
C) do while
D) go to
148. The size of the data type ` double ` in C programming language is _____ A)
16 bits
B) 32 bits
C) 54 bits
D) 64 bits
149. Which of the following is a correct way of representing a variable in C? A)
int 1ram;
B) float _calculate;
C)
int if;
D) int run#fast;
150. An integer constant in ` C ` must have A)
At least one digit
B)
At least one decimal point
C)
A comma along with digits
D)
Digits separated by commas
151. The ` * ` operator stands for ____ . A)
' Address of ' operator
B) ' value at address ' operator
C)
format specifier
D) both A&B
Which of the following is invalid variable name? A)
BASICSALARY
B) _basic
C)
basic-hra
D) hELLO
153. Which of the following is NOT a character constant? A)
‘Thank You’
B)‘Enter values of P, N, R’
C)
‘23.56E-03’
D)
All the above
154. A ` C ` variable cannot start with A)
An alphabet
B)
A number
C)
A special symbol other than underscore
D)
Both B & C above
155. Which of the following statement is wrong?
A)
mes = 123.56 ;
B)
con = 'T' * 'A' ;
C)
this = 'T' * 20 ;
D)
3+a=b;
156. A structure is a collection of______ . A)
different data types scattered throughout memory
B)
the same data type scattered throughout memory
C)
the same data type placed next to each other in memory
D)
different data types placed next to each other in memory
157. The variables which hold addresses of other variables are, A)
array
B) structure
C) pointer
D) both A&C
158. What will be the output of the following code ? main() { int x=10,y=20; if(x==y) printf("\n%d%d",x,y); } A)
10,20
B) No Output
C)
syntax error
D) none of the above
159. A ` while ` loop is knowm as a A)
exit controlled loop
B) entry controlled loop
C)
exit controlled loop
D) none of the above
160. Maximum no of elements in the array declaration int sss[5][8] is________ A)
28
B) 32
C) 35
D) 40
161. Pointer to pointers is a term used to describe A)
pointers whose contents are the address of another pointer
B)
Any two pointers that point to the same variable
C)
Any two pointers that point to variables of the same type
D)
pointers used as formal parameters in a function header
162. An _______ is an integral value used to access an element in an array. A)
constant
B) element
C) index
D) number
163. Which of the following file modes opens a file in the write state for updating? A)
ab
B) a+b
C) rb
D) r+b
164. Which of these results when failure occurs during an open or during either a read or write operation related to file I/O ? A)
error state
B) fail state
C) read state
D) update state
165. Which of the following C functions is used to set file pointer? A)
fwrite
B) fseek
166. * is used to denote_________
C) fread
D) putc
A)
Pointer
B) Addition
C) Division
D) Assignment
167. Structure is a collection of ________elements A)
Same
B) Different
C)
Same or Different D) Same & Different
168. Pointer is nothing but_________ A)
address of variable B)
int
C)
char
D) value of variable
169. Character array is nothing but___________ A)
string
B) int
C) char
D) float
170. Which of the following statement transfers the control to the beginning of the loop? A)
exit
B) break
C)
continue
D) None of the above
171. A ` do-while ` loop is useful when the statements within the loop must be executed: A)
Only once
B) At least once
C)
More than once
D)None of the above
172. A case in ` switch ` statement is terminated by ________ if control should not fall through the successive cases. A)
break
B) break;
C) ;
D) break,
173. The getch() function in ` C ` is ___________ A)
user defined function
B) library function
C)
both of above
D) none of above
174. Scope of local variable is limited to___________ A)
entire program
B) with in function
C)
with in class
D) None of the above
175. Array can be initialized automatically, provided they are declared with following specifiers A)
automatic
B) external
C) static
D) both B & C
176. Which of the following ` C ` statement is syntactically correct? A)
for( );
B) for(;);
C) for(;;)
D) for( , );
177. Which one of the following is not a valid character specification for C A)
special character B)
C)
digit
language ?
control D) space
178. In what sequence the initialization, testing and execution of the body is done in a ` do-while ` loop A)
initialization, execution of the body, testing
B)
Execution of the body, initialization, testing
C)
nitialization, testing, execution of the body
D)
None of the above
179. int *my_pointer;
int barny;
my_pointer=&barny;
*my_pointer=3;
Study the above code and mark which is correct? A)
value of barny becomes 3
B)
value of my_pointer remains unchanged;
C)
both A and B
D)
None of the above
180. enum is a ____________ A)
keyword
B)system defined data type
C)
abstract data type D)
all of the above
181. Difference between ` while ` and ` do-while ` A)
'while' loop executes one or more times and 'do-while' executes zero or more times
B)
Both 'while' loop and 'do-while' executes one or more times
C)
Both 'while' loop and 'do-while' executes zero or more times
D)
'while' loop executes zero or more times and 'do-while' executes one or more times
182. An array is a collection of __________ A)
a set of values with different data types scattered throughout the memory
B)
a set of values with the same data types scattered throughout the memory
C)
a set of values with the same data types placed next to each other in the memory
D)
a set of values with different data types placed next to each other in the memory
183. Which element of the array does the expression num[4] references, where ` num ` is a name of array? A)
Forth
B) Third
C) Fifth
D) First
184. If you don’t initialize a static array, with what value t he elements will be initialised? A)
0
B) an undetermined value
C)
-1
D) the character constant ' \0'
185. The strncat() funtion is used ______ . A)
to copy n characters of a string
B)
to compare n characters of a string
C)
to reverse the string
D)
none of these.
186. Which of the following is not a integer constant in ` C ` ? A)
'C'
B) 123
C) 45
D) 1.2
187. Which of the following data types is not valid in a switch --- case statement? A)
character
B) integer
C) enum
188. Any variable in C starts with a _______ . A)
Number
B) Keyword
D) float
C)
Alphabet
D) None of the above
189. In C, the address of m’s memory location can be determined by the expression A)
*M
B) M&
C) &M
D) M*
190. Which among the following is a unconditional control structure? A)
do-while
B) if-else
C) goto
D) for
191. A ` continue ` statement terminates a_______. A)
function
B) iteration
C)
body of a loop
D) None of the above
192. Constants in ` C ` refer to ___________ A)
A Fixed value that do not change during the execution of the program.
B)
A Fixed value that can change during the execution of the program.
C)
A Fixed value that can change after the compilation of the program.
D)
A Fixed value that can change after linking the program.
193. An array is the _________ data type. A)
Primary
B) User defined
C)
Derived
D) Set
194. The syntax of the array declaration is: A)
datatype nameofarray [size];
B) nameofarray [size];
C)
datatype nameofarray ;
D) all of above
195. If ` a ` is a variable defined in a ` C ` program then &a denotes the ______ . A)
content of a
B) address of a
C)
Both A and B
D) none of these
196. Which of the following statements determines whether the contents of string1 are same as contents of string2 or not? A)
if (string1 == string2)
B)
if (string1, string2)
C)
if (strcmp(string1,string2) ==0 )
D)
if (strcmp(string1, string2) < 0)
197. The _______ format specification is used to write a long integer variable. A)
%d
B) %dd
C) %lf
D) %ld
198. A ` break ` statement is used _______ . A)
to terminate a loop and execute the next statement
B)
to skip a loop and terminate the program
C)
to continue a loop and execute the next statement
D)
execute the next statement
199. Which of the following function is used to read the input from a string?
A)
scanf
B) fscanf
C) fprintf
D) sscanf
200. In ` C ` , a semicolon is used ____________. A)
to terminate a statement
B) to break a loop
C)
to give a comment
D) none of these
201. A ` switch ` statement is used to make a decision _________________. A)
to switch the processor to execute some other program
B)
between two alternatives
C)
amongst many alternatives
D)
none of these
202. When applied to a variable, what does the unary "&" operator yield? A)
The variable's address
B)
The variable's right value
C)
The variable's binary form
D)
The variable's value
203. To delete a dynamically allocated array named `a`, the correct statement is A)
delete a;
B) delete a[0];
C)
delete []a;
D) delete [0]a;
204. Identify the invalid keyword in the following list. A) 205.
integer
B) char
C) float
D) long int
Which of the following is not a valid data type In ` C ` ? A)
char
B) float
C) int
D) logical
206. && is used as a __________ A)
operand
B) Mathematical operator
C)
logical operator
D)None of the above
207. What is the difference between declaration and a definition of a variable? A)
Both can occur multiple times, but a declaration must occur first.
B)
There is no difference between them.
C)
A declaration occurs once, but a definition may occur many times.
D)
A definition occurs once, but a declaration may occur many times.
208. Array is the collection of ----------- data type. A)
Disimilar
B) Similar
C) None of these
D) two
1.
B
2.
C
3.
C
4.
A
5.
B
6.
C
7.
D
8.
B
9.
C
10.
B
11.
C
12.
D
13.
C
14.
B
15.
C
16.
B
17.
D
18.
C
19.
B
20.
B
21.
C
22.
A
23.
A
24.
A
25.
D
26.
A
27.
C
28.
A
29.
C
30.
B
31.
C
32.
C
33.
C
34.
B
35.
C
36.
C
37.
B
38.
C
39.
C
40.
B
41.
C
42.
A
43.
A
44.
C
45.
C
46.
C
47.
B
48.
C
49.
B
50.
D
51.
B
52.
C
53.
C
54.
A
55.
A
56.
B
57.
C
58.
D
59.
A
60.
B
61.
D
62.
C
63.
C
64.
D
65.
B
66.
C
67.
D
68.
C
69.
B
70.
A
71.
B
72.
B
73.
C
74.
C
75.
A
76.
D
77.
D
78.
C
79.
A
80.
B
81.
D
82.
A
83.
A
84.
B
85.
C
86.
A
87.
A
88.
A
89.
B
90.
B
91.
B
92.
B
93.
B
94.
A
95.
D
96.
A
97.
D
98.
D
99.
D
100.
C
101.
C
102.
D
103.
A
104.
D
105.
C
106.
C
107.
A
108.
D
109.
A
110.
A
111.
D
112.
B
113.
A
114.
D
115.
D
116.
D
117.
B
118.
B
119.
B
120.
A
121.
C
122.
D
123.
C
124.
C
125.
A
126.
C
127.
B
128.
C
129.
C
130.
A
131.
D
132.
A
133.
C
134.
A
135.
B
136.
C
137.
A
138.
B
139.
D
140.
B
141.
D
142.
A
143.
A
144.
D
145.
D
146.
A
147.
C
148.
D
149.
B
150.
A
151.
B
152.
C
153.
D
154.
D
155.
D
156.
D
157.
C
158.
B
159.
-
160.
D
161.
A
162.
C
163.
B
164.
A
165.
B
166.
A
167.
C
168.
A
169.
A
170.
C
171.
B
172.
B
173.
B
174.
B
175.
D
176.
C
177.
B
178.
A
179.
C
180.
A
181.
D
182.
C
183.
C
184.
A
185.
A
186.
D
187.
D
188.
C
189.
C
190
C
191.
B
192.
A
193.
C
194.
A
195.
B
196.
C
197.
D
198.
A
199.
D
200.
A
201.
C
202.
A
203.
A
204.
A
205.
D
206.
C
207.
C
208.
A
1. Pointers can be used to achive …………………….. a] Call by function c] call by name
b] call by reference d] call by procedure
2. Correct declaration of pointer variable p1,p2
3:
a] int p1,p2;
b] int *p1,p2;
c] int p1,*p2
d] int *p1,*p2
What is the output of this C code? #include void foo(int*); int main() { int i = 10; foo((&i)++); } void foo(int *p) { printf("%d\n", *p); }………………………….
a) 10 c)
b) garbage value Compile time error
d) code crash
4:--- #include void foo(int*); int main() { int i = 10, *p = &i; foo(p++); } void foo(int *p) { printf("%d\n", *p); a) 10
b) garbage value
c)
Compile time error
d) code crash
5:-#include void foo(float *); int main() { int i = 10, *p = &i; foo(&i); } void foo(float *p) { printf("%f\n", *p); }
a)
10.000000
c)
b) 0.000000
Compile time error
d) syntax error
………………………..
6:-- #include int main() { int i = 97, *p = &i; foo(&i); printf("%d ", *p); } void foo(int *p) { int j = 2; p = &j; printf("%d ", *p); }
a)
2 97
c)
b) 2 2 Compile time error
………………………..
7:--#include int main() { int i = 97, *p = &i; foo(&p); printf("%d ", *p);
d) syntax error
return 0; } void foo(int **p) { int j = 2; *p = &j; printf("%d ", **p); }
a)
2 97
c)
b) 2 2 Compile time error
d) syntax error
………………………..
8:-----When the ___________ is present in front of a variable name, it represents the address of that variable. 1. 2. 3. 4.
asterisk ( * ) conditional operator ampersand ( & ) semicolon ( ; )
………………………..
9:--- A pointer variable may be initialized with 1. 2. 3. 4.
any non-zero integer value any address in the computer's memory the address of an existing variable a and c only
………………………..
10:-- A pointer variable is designed to store ________. 1. 2. 3. 4.
any legal C++ value only floating-point values a memory address a float value
………………………
11-- We should use the delete operator for objects that were _______
a)
never used
c)
created with the new operator
b)… not correctly initialized
d) dereferenced inappropriately
………………………….
12--- #include< stdio.h> int main() { char arr[20]; int i; for(i=0;i<10;i++) *(arr+i) = 65+i; *(arr + i) = '\0'; printf("%s",arr); return(0); } a) ABCDEFGHIJ c)
JJJJJJJJJJ
…………………….
13:-- The size of a pointer data type is a. 2 bytes b. 4 bytes c. the same size as an int d. dependent on the machine ………………………….. 14—
Given the C declaration float t1, *t2=&t1; which variable contains "garbage"? a. t1 b. t2 c. t2 d. all of the above. ………………… 15—
.What would be the output of the following program? #include "stdio.h" main( ) { printf( "%d %d", sizeof(NULL),sizeof(" " ) ); }
b) AAAAAAAAAA d) None Of These
(a) 1 1 (b) 1 2 (c) 2 1 (d) 2 2 …………….
16 Are the three declarations char **apple, char *orange[ ], and char cherry [ ] [ ] same? (a) Yes (b) No (c) Can't say (d) None ………………..
17 Can two different near pointers contain two different addresses but refer to the same location in memory? (a) Yes (b) No (c) Can't say (d) None ………………………..
18 Would the following program give any warning on compilation? #include "stdio.h" main( ) { int *p1,i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; } (a) Yes (b) No (c) Can't say (d) None ………………….
19 Would the following program give any warning on compilation? #include "stdioh" main( ) { float *p1,i=25.50;
char *p2; p1=&i; p2=&i; } (a) Yes. Suspicious pointer conversion in function main (b) No (c) Can't say (d) None …………………..
20 What warning would be generated on compiling the following program? main( ) { char far *scr; scr=0*B8000000; *scr = 'A'; } (a) Suspicious pointer conversion in function main (b) Non-portable pointer assignment in function main (c) Can't say (d) None
21 .How would you eliminate the warning generated on compiling the following program? main( ) { char far *scr; scr=0*B8000000; *scr = 'A'; } (a) Use the typecast scr= (char *far ) 0*B8000000; (b) Use the typecast scr= (char far * ) 0*B8000000; (c) Use the typecast scr= (char **far ) 0*B8000000; (d) Use the typecast scr= (char far ** ) 0*B8000000; …………………
22 In a large data model (compact, large, huge) all pointers to data are 32 bits long,whereas in a small data model (tiny, small,medium) all pointers are 16 bits long (a) True
(b) False (c) Can't say (d) None …………
23 . A near pointer uses the contents of CS register (if the pointer is pointing to code) or contents of DS register (if the pointer is pointing to data) for the segment part,whereas the offset part is stored in the 16-bit near pointer (a) True (b) False (c) Can't say (d) None 24. What would be the output of the following program? main( ) { char far *a=0*00000120; char far *b=0*00100020; char far *c=0*00120000; if(a==b) printf("\nHello"); if(a==c) printf("\nHi"); if(b==c) printf("\nHello Hi"); if(a>b && a>c &&b>c) printf("\nBye"); } (a) Hello (b) Hi (c) Hello Hi (d) Bye
25. What would be the output of the following program? main( ) { char huge *a=0*00000120; char huge *b=0*00100020;
char huge *c=0*00120000; if(a==b) printf("\nHello"); if(a==c) printf("\nHi"); if(b==c) printf("\nHello Hi"); if(a>b && a>c &&b>c) printf("\nBye"); } (a) Hello (b) Hi (c) Hello Hi (d) all 26. Are the expressions *ptr++ and ++*ptr same? (a) Yes (b) No (c) Can't Say (d) None 27.Can you write another expression which does the same job as ++*ptr? (a) (ptr*)++ (b) *ptr++ (c) ptr*++ (d) (*ptr)++
28. What would be the equivalent pointer expression for referring the same element as a[i][j][k][l]? (a) *(*(*(*(a+i)+j)+k)+l) (b) *(*(*(*a[i])[j])[k])[l]) (c) both (d) None
29. What would be the output of the following program ? main( ) { int arr[ ]={12,13,14,15,16}; printf("\n%d %d %d",sizeof(arr),sizeof(*arr),
sizeof(arr[0])); } (a) 10 4 4 (b) 10 4 2 (c) 10 2 2 (d) 10 2 4
30.What would be the output of the following program assuming that the array begins at location 1002? main( ) { int a[3][4]={1,2,3,4, 5,6,7,8, 9,10,11,12 }; printf( "\n%u %u %u",a[0]+1,*(a[0]+1),*(*(a+0)+1)); } (a) 1004 2 2 (b) 1004 4 4 (c) 1002 2 2 (d) 1002 4 4
31. What would be the output of the following program assuming that the array begins at location 1002? main( ) { int a[2][3][4]={ { 1,2,3,4, 5,6,7,8, 9,1,1,2 }, { 2,1,4,7, 6,7,8,9, 0,0,0,0 } }; printf("\n%u %u %u %d",a,*a,**a,***a); } (a) 1002 1002 1002 2
(b) 1002 1002 1002 1 (c) 1004 1004 1004 1 (d) 1004 1004 1004 2
32. In the following program how would you print 50 using p? main( ) { int a[ ]={10,20,30,40,50}; char *p; p = (char *) a; } (a) printf("\n%d",*( (int *)p+4) ); (b) printf("\n%d",( (int *)p+4) ); (c) printf("\n%d",*( (int )p+4) ); (d) printf("\n%d",*( (int **)p+4) );
33. In the following program add a statement in the function fun( ) such that address of a gets stored in j main( ) { int *j; void fun(int **); fun(&j); } void fun(int **k) { int a=10; } (a) *k=&a; (b) &a=*k; (c) &k=*a; (d) *a=&k;
34.How would you declare an array of three function pointers where each function receives two ints and
returns a float? (a) float (arr[3])(int,int); (b) int (arr[3])(float,float); (c) int (*arr[3])(float,float); (d) float(*arr[3])(int,int); 35. What does the following statement mean? int (*fp)(char*) a) pointer to a pointer b) pointer to an array of chars c) pointer to function taking a char* argument and returns an int d) function taking a char* argument and returning a pointer to int
36. The operator used for dereferencing or indirection is ____ a) * b) & c) -> d) –>>
37. Choose the right option string* x, y; a) x is a pointer to a string, y is a string b) y is a pointer to a string, x is a string c) both x and y are pointer to string types d) none of the mentioned
Explanantion:* is to be grouped with the variables not the data types. 38. Which one of the following is not a possible state for a pointer. a) hold the address of the specific object b) point one past the end of an object c) zero d) point to a tye
Explanation:A pointer can be in only 3 states a,b and c. 39 Which of the following is illegal? a) int *ip; b) string s, *sp = 0; c) int i; double* dp = &i; d) int *pi = 0;
Explanation:dp is initialized int value of i. 40. What will happen in this code? int a = 100, b = 200; int *p = &a, *q = &b; p = q; a) b is assigned to a b) p now points to b c) a is assigned to b d) q now points to a Explanation:Assigning to refrence changes the object to which the refrence is bound. 41 The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is a) int **fun(float**, char**) b) int *fun(float*, char*) c) int ***fun(float*, char**) d) int ***fun(*float, **char)
42 Prior to using a pointer variable it should be A.
Declared
B.
Initialized
C.
Both declared and initalized
D.
None of these
Explanation : Using a pointer variable, without initializing it, will be disastrous, as it will have a garbage value ………
43 The indirection operator in C is the a.&
b.@ c.* d.! ……
44. The indirection operator in C goes ______the variable that it operates on. a. in front of b. in back of c.both d noe ………….
45. When the * is used in a declaration it is accomplishing indirection. a. true b. false (c) Can't say (d) None ………..
46. When a pointer variable is declared, its value is garbage, i.e. it points to garbage. a. true b. false (c) Can't say (d) None ……………
47. Which function does the asterisk in C not have? a. indirection b. declares a pointer
c. provides the address of its operand d. multiplication ………..
48. Given the C code segment below. int *p, s, *t=&s, u=s; s=100; ++(*t); p=t; ++(*p); -u; After the above code segment, *p would contain a. 99 b. 100 c. 101 d. 102 49 . Given the C code segment below. int *p, s, *t=&s, u=s; s=100; ++(*t); p=t; ++(*p); -u;
After the above code segment, u would contain a.99 b.1L00 c. 101 d. 102
50 Given the C code segment below. int *p, s, *t=&s, u=s; s=100; ++(*t); p=t; ++(*p); -u; After the above code segment, *t would contain a. 99 b. 100 c. 101 d. 102 51. Given the C code segment below. int *p, s, *t=&s, u=s; s=100; ++(*t); p=t;
++(*p); -u; After the above code segment, s would contain a. 99 b. 100 c. 101 d. 102 52. A memory address has its own unique data type. a. true b. false (c) Can't say (d) None 53. The size of a pointer varies, depending on what it points to. a. true b. false (c) Can't say (d) None 54. The scanf function requires addresses rather than variables for its arguments. a. true b. false (c) Can't say (d) None 55. The ____ conversion code prints out addresses in pointer types. a. %x b. %t
c. %p d. %r 56. Addresses represented by pointer types are chosen by C, and the programmer has no control over them. a. true b. false (c) Can't say (d) None 57. A float declaration can define both pointers to floats and regular float variables in the same declaration. a. true b. false (c) Can't say (d) None 58. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code. x is not initialized in its declaration. a. true b. false (c) Can't say (d) None 59. int *x;
int y,t=-1; int *w,*z=&y; x=&y; in the above code y is initialized to -1. a. true b. false (c) Can't say (d) None 60. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code The value of *x is a. the address of y b. -1 c.0 d. garbage 61. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code z and x point to the same memory location.
a. true b. false (c) Can't say (d) None 62. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code The value of *y is _. a. garbage b. undetermined c. an error, since y cannot be dereferenced d. -1 63. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code No pointer defined above points to t's memory location. a. true b. false (c) Can't say (d) None 64.
int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code Although *w is garbage, w is not. a. true b. false (c) Can't say (d) None 65. int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code w and z both point to y. a. true b. false (c) Can't say (d) None 66. Which of the following would represent the value of -1? a. *t b. &t c. *x d. *&t 67. int *x; int y,t=-1;
int *w,*z=&y; x=&y; in the above code The type of *x is a. a type that cannot be determined b. int c. long int d. pointer to an int 68. . int *x; int y,t=-1; int *w,*z=&y; x=&y; in the above code The type of &y is a. a type that cannot be determined b. int c. long int d. pointer to an int 69. Both the indirection operator and the address-of operator a. must be used in declarations b. are binary operators c. are unary operators d. are not overloaded 70. Pointers cannot be passed to functions. a. true b. false
(c) Can't say (d) None 71. Given the declaration float x, *z=&x; which scanf would successfully read in a float value into x? a. scanf("%f", x); b. scanf ("%f",z); c. scanf("%f " ,*z) ; d. all of the above 72 Consider the declaration: char x[]="WHATIZIT"; char *y="WHATIZIT"; The output of puts(x) an puts(y) will be A
Will be the same
B.
Different
C.
Not related
D.
Error
73 Consider the declarations: char first (int(*)(char,float)); int second(char,float); Which of the following function invocation is valid? A.
First(*second); B.
First(&second);
C.
First(second);
D.
None fo these
74 In C a pointer variable to an integer can be created by the decalaration A.
int p*;
B.
int *p;
C.
int +p;
D.
int $p;
75 Which of the following is most appropriate? A.
int*matrix; .....; free(void) matrix;
B.
int*matrix; .....; free (matrix);
C.
int*matrix; .....; if(matrix!=null) free(void*)matrix;
D.
None fo these
76
77
* is a ________________ a] Indirect operator
b]Structure member reference operator
c] Assignment operator
d] Address of operator
Are the expression *ptr++ and ++*ptr are same?
(a) Yes (b) No (c) Can't say (d) None Explanation: *ptr++ increments the pointer and not the value, whereas the ++*ptr increments the value being pointed by ptr 78
Will the program compile?
#include int main() { char str[5] = "IndiaBIX"; return 0; } (a) Yes
(b) No (c) Can't say (d) None Explanation: C doesn't do array bounds checking at compile time, hence this compiles. But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'. GCC would give you a warning. 79
What is (void*)0?
A.Representation of NULL pointer B.Representation of void pointer C.Error D.None of above
80
Can you combine the following two statements into one?
char *p; p = (char*) malloc(100); A.char p = *malloc(100); B.char *p = (char) malloc(100); C.char *p = (char*)malloc(100); D.char *p = (char *)(malloc*)(100);
81
In which header file is the NULL macro defined?
A.stdio.h
B
stddef.h
C.stdio.h and stddef.h
D.
math.h
Explanation:
The macro "NULL" is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h. 82 If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable? A.
$
.
C.*
B.
&
D.
-> Answers
1.
b
2.
d
3.
c
4.
a
5.
b
6.
a
7.
b
8.
c
9.
b
10.
c
11.
c
12.
a
13.
d
14.
c
15.
c
16.
b
17.
b
18.
b
19.
a
20.
b
21.
b
22.
a
23.
a
24.
d
25.
d
26.
b
27.
d
28.
a
29.
c
30.
a
31.
b
32.
a
33.
a
34.
d
35.
c
36.
a
37.
a
38.
d
39.
c
40.
b
41.
c
42.
c
43.
c
44.
a
45.
b
46.
a
47.
c
48.
d
49.
a
50.
d
51.
d
52.
a
53.
b
54.
a
55.
c
56.
a
57.
a
58.
a
59.
b
60.
d
62.
c
63.
64.
b
65.
b
61.
a
66.
d
67.
71.
b
72.
76.
a
81.
c
b
a
68.
d
69.
c
70.
b
a
73.
c
74.
b
75.
c
77.
b
78.
a
79.
a
80.
c
82.
d
1
An algorithm is made up of 2 modules Ml and M2. If order of M1 is f(n) and M2 is g(n) then the
order of the algorithm is A. max (f (n) ,g (n)) B. min (f (n) ,g (n) ) C. f (n) + g (n) D.f (n) x g (n ) Answer: Option A 2.There are 4 different algorithms AI, A2, A3, A4 to •solve a g iven problem with the order Iog(n),
log(log(n)), nIog(n) ,n / log(n) respectively. Which is the best algorithm? A. A1 B. A2 C. A4 D. A3 Answer: Option B 3.
The concept of order (Big O) is important because
A. it can be used to decide the best algorithm algorithm that solves a given problem 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. Both(a) and (b) D. none of the above Answer: Option C 4
The time complexity of an algorithm T(n), where n is the input size, is given by
T( n) = T( n - 1) + 1/n 1/n if n > 1
The order of this algorithm is A. log n B. n C. n2 D. nn Answer: Option A 5
The order of an algorithm that finds whether a given Boolean function of 'n' variables, produces
a 1 is A. constant B. linear C. logarithmic D. exponential Answer: Option A 6
In the worst case, the number of comparisons needed to search a single linked list of length n
for a given element is A. logn B. n/2 C. log(n/2)-1 D. n Ans. Option D 7.
1: A mathematical-model 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 Answer: Option B
8.
Representation of data structure in memory is known as:
A. Recursive
B. Abstract data type C. Storage structure D. File structure Answer: Option B. 10.
The term data structure refers to -----------and interelationship beween them.
A.Programming language Statements . B.Coding Standards. C.Organization of data elements. D.None of this Answer: Option C 11
Array is an example of.
A.Static data structure. B.Dynamic Data Structure. C.Linear data structure. D.Both A and C
Ans: Option D 12
Data structure in which one predecessor may have one or more successor.
A.Linear B.Primitive C.Non-Linear D.None of the above
Ans:Option C 13.
What is Data Structure ?
a.
Way to organize data
b.
Accessing of data elements in specified manner
c.
Organization of mathematical and logical concepts
d.
All of Above
Ans:Option A 14.
Two main measures for the efficiency of algorithm are
A.Time and space. B.Processor and memory C.Data and Space. D.Complexity and capacity Ans:Option A 15.
Time factor while determining the efficiency of algorithm is measured by.
A.Counting Microseconds. B.Counting no of statements. C.Counting no of key opeartions. D.Counting key algorithm Ans:Option C 16
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 Ans:Option A
17 18
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 situation d. for none of above situation Ans:B 19.
Which of the following data structures are indexed structures?
a. linear arrays b. linked lists c. both of above d. none of above Ans:A 20
Which of the following data structure store the homogeneous data elements?
a. Arrays b. Records c. Pointers d. None Ans:A 21
Which of the following data structure can store the nonhomogeneous data elements?
a. Arrays b. Records c. Pointers d. None Ans:B
22
Which of the following data structure is linear type?
a.Strings b.Lists c:Queues d:All of above Ans:D 23
3.Which of the following data structure is non-linear type?
a.Strings bLists c. Stacks d.None of above Ans:D 24
Which of the following case does not exist in complexity theory
A. Best case B. Worst case C. Average case D. NULL case Answer :D 25
The time required to search an element in a linked list of length n is
A. O(log2 n) B. O(n) C. O(1) D. 0 (n2) Answer :D 26
27
Consider the following two functions.
f(n) = n3, if 0≤n < 10,000
n2, otherwise g (n) = n, if 0≤n < 100
n25n,otherwise Which of the following is/are true? A. f(n) is O(n3) B. g(n) is O(n2) C. O(f(n)) is same as O(g(n)) D. Both(b) and (c Answer: Option D 28
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 Answer : A. 29.
Data which can't be divided further into meaningful pieces is
A:Atomic data B:primitive data C:Composite data D:None of the above Answer:A 30
abstract data type is where :
A:memory required is less as compare to builtin data type
B:Implementation details are kept hidden. C:Memory required is greater than built in data type. D:None of the above. Answer: B 31 Which of the following is not the part of ADT description? A) Data B) Operations C) Both of the above D) None of the above Ans: D 32
. …………… is not the component of data structure.
A) Operations B) Storage Structures C)
Algorithms
CI)
None of above
Ans: D 33
Which data structure is best suited to print the documents in the printer
A. Stacks B. Queues C. Both Stacks and Queues D. Arrays Answer: B 34.
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. housefull d. saturated Answer: B 35.
There are 4 different algorithms A1, A2, A3, A4 to solve a given problem with the order log (n),
loglog (n), nlog (n), n/log (n) respectively. Which is the best algorithm? (a) A1 (b) A2 (c) A4 (d) A3 Ans: (b) 36.
What is the worst-case time for serial search finding a single item in an array?
A. Constant time B. Logarithmic time C. Linear time D. Quadratic time Ans: (d)
37
What term is used to describe an O(n) algorithm.
A. Constant B. Linear C. Logarithmic D. Quadratic Ans: (b) 38
Which of the following is primitive type?
A. Byte B. Integer C. Float
D: Choice (C) & (D)
Ans:D
1.The time complexity of linear search algorithm over an array of n elements is A.O (log2 n) B.O(n) C.O(n log2 n) D.0 (n2) ANSWER: B 2.The time required to search an element in a linked list of length n is A.O(log2 n) B.O(n) C.O(1) D.0 (n2) ANSWER: B 3.The worst case time required to search a given element in a sorted linked list of length n is A.O(1) B.O(log2 n) C.O(n) D.O(n log2 n) ANSWER: C 4.For a linear search in an array of n elements the time complexity for best, worst an d average case are ......., ....... and ........ respectively A.O(n), O(1), and O(n/2) B.O(1), O(n) and O(n/2) C.O(1),O(n) and O(n) D.O(1), O(n) and (n-1/2) ANSWER: C 5.Using the standard algorithm, what is the time required to determine that a number n is prime ? A.Linear time B.Logarithmic time C.Constant time D.Quadratic time ANSWER: A 6.Which of the following is false ? A.A serial search begins with the first array element
B.A serial search continues searching, element b y element, either until a match is found or until the end of the array is encountered C.A serial search is useful when the amount o f data that must be search is small D.For a serial search to work, the data in the array must be arranged in either alphabetical or numerical order ANSWER: D 7.The average successful search time for sequential search o n 'n' items is A.n/2 B.(n-1)/2 C.(n+1)/2 D.log (n)+1 ANSWER: C 2.BINARY SEARCH 8.A search begins the search with the element that is located in the middle of the array A.serial B.random C.parallel D.binary ANSWER: D 9.Suppose DATA array contains 1000000 elements. Using the binary search algorithm, one requires only about n comparisons to find the location of an item in the DATA array, then n is A.60 B.45 C.20 D.None of these ANSWER: C 10.The data for which you are searching is called A.search argument B.sorting argument C.detection argument D.binary argument ANSWER: A 11.Which of the following is false ? A.A binary search begins with the middle element in the array B.A binary search continues having the array either until a match is found or until there are no more elements to search C.If the search argument is greater than the value located in the middle of the binary, the binary search continues in the upper half of the array D.For a binary search to work, the data in the array must be arranged in either alphabetical or numerical order ANSWER: C
12.The order of the binary search algorithm is A.n B.n2 C.nlog(n) D.log(n) ANSWER: Option D Let there be ‘n’ items to be searched, After the first search the list is divided into two, each of length n/2. After the next search, 2 lists, each of length n/4 and so on. This successive division has to stop when the length of lists becomes 1. Let it happen after k steps. After the k steps, n/2k=1. Solving, k = log2n. Hence the order is log(n). 13.A characteristic of the data that binary search uses but the linear search ignores is the___________ A.Order of the elements of the list B.Length of the list C.Maximum value in list D.Type of elements of the list ANSWER: A 2.SORTING 1.BUBBLE 14.Which of the following sorting methods would b e most suitable for sorting a list which is almost sorted A.Bubble Sort B.Insertion Sort C.Selection Sort C.Quick Sort ANSWER: A 15.A sort which compares adjacent elements in a list and switches where necessary is A.insertion sort B.heap sort C.quick sort D.bubble sort ANSWER: D 16.Which of the following sorting procedure is the slowest ? A.Quick sort B.Heap sort C.Shell sort D.Bubble sort ANSWER: D
17.The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in ascending order, using bubble sort is A.11 B.12 C.13 D.14 ANSWER: D 18.A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec, it can approximately sort A.400 names B.800 names C.750 names D.800 names ANSWER: A Explanation . For sorting 200 names bubble sort makes 200x(199/2)= 19900 comaprisons. The time needed for 1 comparison is 200 sec (approximately). In 800 sec it can make 80,000 comparisons. We have to find n, such that n(n-1)/2= 80,000. Solving, n is approximately 400. 19.Given a file of size n the number of times a given file is passed through in bubble sort is A.n2 B.n - 1 C.n log n ANSWER: B 20.In bubble sort, for a file of size n, after p iterations number of records in proper positions is A.n - p B.n - p + 1 C.p ANSWER: A 21.For a file of size n, during each pth pass the number of last records left out are A.n - p B.p C.p - 1 ANSWER: C 22.Total number of comparisons in bubble sort is A.O(n log n) B.O(n^2) C.O(n) ANSWER: B 2.SELECTION
21.A sort which iteratively passes through a list to exchang e the first element with any element less than it and then repeats with a new first element is called A.insertion sort B.selection sort C.heap sort D.quick sort ANSWER: B 22.Which of the following sorting methods will be the best if number of swappings done, is the only measure of efficienty? A.Bubble sort B.Selection sort C.Insertion sort D.Quick sort ANSWER: B 23.What is the number of swaps required to sort n elements using selection sort, in the worst case? A.T(n) B.T(n log n) C.T(n2) D.T(n2 log n) ANSWER: A Explanation . Note that we are concerned about the swaps, not the comparisons. In the best case, there is no need for any swap. The best case scenario is when the given list of elements is already in sorted order. In the worst case, we need (n-1) swaps. For example, consider the list 10, 5, 6, 7, 8, 9. We need 5 swaps. To conclude, 0 = (the number of required swaps) < n 24.Staright selection sort is basically a method of repeated A.interchange B.searching C.position adjustment ANSWER: C 25.Number of selections required to sort a file of size N by straight selection requires a.N - 1 b.log N c.O(N2) ANSWER: A 26.For sorting a file of size n by straight selection sort, the number of comparisons made in the first pass is a.n b.n - 1
c.n(n - 1)/2 ANSWER: B
3.INSERTION 27.Which of the following sorting method is stable ? A.insertion sort B.Quick sort C.Shell sort D.Heap sort ANSWER: A 28.The way a card game player arranges his cards as he picks them up one by one, is an example of A.bubble sort B.Selection sort C.insertion sort D.merge sort ANSWER: C 29.You want to check whether a given set of items is sorted. Which of the following sorting methods will be most efficient if it is already in sorted order? A.Bubble sort B.Selection sort C.Insertion sort D.Merge Sort ANSWER: C 4.MERGE 30.Which of the following sorting algorithms does not have a worst case running time of O(n2)? A.Insertion sort B.Merge sort C.Quick sort D.Bubble sort ANSWER: B 31.Merge sort uses A.divide and conquer strategy B.backtracking approach C.heuristic search D.greedy approach ANSWER: A
32.Assume 5 buffer pages are available to sort a file of 105 pages. The cost of sorting using mway merge sort is A.206 B.618 C.840 D.926 ANSWER: C Explanation . In the first pass we can create [105/5] = 21 sorted sub-files, each 5 pages long. In the second pass by 4-way merging (4 because one of the 5 available buffers has to be reserved for holding the output), one can create [21/4] = 6 sorted sub-files, each 20 pages long (except the last). Again applying 4-way merge sort, we get create [6/4] = 2 sorted sub-files. These two can be merged to get the final sorted file. We need a total of 4 passes. Total cost will be 2 x 105 x 4 = 840 units. 5.QUICK
33.A desirable choice for the partitioning element in quick sort is A.First element of the list B.Last element of the list C.Randomly chosen element of the list D.Median of the list Answer: A 34.Quick sort is also known as A.Merge sort B.Heap sort C.Bubble sort C.None of these ANSWER: D 35.A sort which relatively passes through a list to exchang e the first element with any element less than it and then repeats with a new first element is called A.Insertion sort B.Selection sort C.Heap sort D.Quick sort ANSWER: D 36.The best average behaviour is shown by A.Quick Sort B.Merge Sort C.Insertion Sort C.Heap Sort ANSWER: A