Chapter 1 to 6
Chp. 5 to 7 Programming Language
1. The three programming structures are:
a. Sequence, decision, and repetition. b. Process, decision, and alternation.
c. Sequence, definition, and process. d. Relation, comparison, and process.
2. Which programming structure executes program statements in order?
a. Relation b. Decision c. Sequence d. Repetition
3. Another term for a computer making a decision is:
a_ Sequential. b. Selection. c. Repetition. d. Iteration:.
4. Which programming structure makes a comparison?
a. Relation b. Decision c. Sequence d. Repetition
5. An expression that uses a relational operator is known as:
a. Condition. b. Decision. c. Series.
6. Relational operators allow you to numbers-
a. Compare b. Add c. Multiply
7. When a relational expression is false, it has the value.
a. Zero b. one c. Less than 0 d. None
8. You can use a decision statement to:
a. Run a series of statements if a test fails. b. Test a series of conditions.
c. Test whether a condition is true or false. d. All
9. Operators that are used to compare operands and decide whether the relation is true or false
are called:
a. Arithmetic operators. b. Logical operators.
c. Syntax operators. d. Relational operators
10. Which of the following statements is the simplest form of a decision structure?
a. Select...Case b. If statement c. Try...Catch...Finally d.
Nested if
Chapter 1 to 6
12. In if statement, true is represented by:
a. 0 b.1 c. 2 d. 3
13. Which of the following is used for making two way decision:
a. if-else b. if c. nested if d. switch
14. Conditional operator is an alternative of:
a. if b. if-else c. nested if d. None
15. The conditional portion of the If statement can contain:
a. Any valid constant. b. Any expression that can be evaluated to a Boolean value.
c. Any valid variable. d. Any valid constant or variable.
16. An if statement within an if statement is called:
a. A nested if statement. b. A branched if statement.
c. A infinite if statement d. None
17. What does a compound condition use to join two conditions?
a. Relational Operator b. Logical Operator c. Relational Results d. Logical Results
18. Which is an example of multiple branches from single expression?
a. If stztement b. switch statement c. while loop d. All
19. Which of the following is valid case statement in a switch?
a. case 1: b. case x<4: c. case 'abi: d. case 15:
20. A case can be defined as:
a. An individual condition to test. c. A statement that includes an If statement.
21. The first line in switch block contains:
a. The value of the first criterion. B. The statement to be executed if the first criterion is true.
c. The expression to be evaluated. d. The statement to be executed if none of the criteria are
true.
22. The Case block ends with:
a. End Select b. End Case. c. break
23. Which of the following is equivalent to (p >= q)?
a. p < q b. !(p < q) c. p > q
24. Another term for a conditional operator is:
Chapter 1 to 6
a. Ternary b. Binary c. Byte
25. Conditional operator takes:
a. Three operands b. Two operands c. One operand
26. Which operator in C++ is called a ternary operator?
a. if b. ++ c. ? d. ()
27. All of the following are relational operators EXCEPT:
a.!=. b. I I . c.= d. >=.
28. Which of the following returns True if A = 25 and B - 35:
a. MB b. A>=13 c. A!=3 d. A=B
29. For A = 4 and B = 4 which evaluates as true?
a. A 0 B b. A < B c. A > B d. A>=B
30. What operator is used in a compound condition to join two conditions?
a. Relational Operator b. Logical Operator c. Relational Results d. Logical Results
31. Operators that perform operations on Boolean data are:
a. Arithmetic operators. B. Logical operators’ c. Relational operators. D. Math
Operators
32. Which of the following symbol is used for OR operator?
a. I I b.&& c. ! d. None
33. Which of the following symbol is used for AND operator?
a. I I b. && c. ! d. None
34. Which of the following symbol is used for NOT operator?
a. I I b. && c. ! d. None
35. All of the following are logical operators EXCEPT:
a. && b. H c. ! d. =
36. Which of the following is not a C++ relational operator?
a. = - b. < c. != d.&&
37. Which C++ logical expression correctly determines whether the value of beta lies between 0
and 100?
a. 0 < beta < 100 c. (0 < beta) && (beta < 100)
Chapter 1 to 6
b. 0 < beta && beta < 100 d. b and c above
38. If the int variables i, j, and k contain the values 3, 20, and 100, respectively, what is the value
of the following logical expression:
j <4 I I j == 5 eat <= k3 < 4 I 20 == &Se 3 < 100
a. 3 bialse b. false c. 20 d. true
39. If p is a Boolean variable, which of the following logical expressions always has the value
false
a. p&&p b.PIIP c. p && !p d. PII!P
40. What is output of the following code?
if ((1 ==1) I I (2,2) I I (3==3))
d. True cout«"Good";
else
cout«"Bad";
a. Good b. Bad c. goodbad d. not output
41. What is output of the following code?
int x=1;
int y=2;
int z=3;
if ((x==y) I I (y==z) 11 (z==2)) printf("YES"); else printf("NO");
a. No b. YES c. yes d. No Output
42. What is output of the following code? if
(1==2) cout«"Hello";
else
if (2=1) cout«"World";
a. No output b. Hello c. World d. Helloworld
43. After execution of the following code, what will be the value of angle if the input value is 0?
cin >> angle;
if (angle > 5)
angle = angle + 5,
Chapter 1 to 6
else if (angle > 2)
angle = angle + 10;
else
angle = angle + I5:
a 15 b. 25 c. 35 d.40
44. What is output of the following code?
int p. q, r,
p= 10:
q=3
r = 2;
• if ((p + q) < 14 && (r < q — 3))
cout <S r;
else
cout « p,
a. -2 b. 4 c9 d. -4
45. What is output of the following code?
If(('A -=='A') && (B'==B) && (C==C))
cout« 'Equal";
else
cout«"Not Equal". of the following
a. Not Equal b. Equal c. No output d. Both a and b
46. What is output of the following
if(9<5)
cout«-x":
else
If(== 6)
cout«"#";
else
Chapter 1 to 6
cout<<”@”;.
a.x b. # c. @ d. None
47. What is the output of the following C++ Code for the input data 25 35 20 cm » a ›.-.• c
If(a>b&&a>c)
m=a
else if(b > c)
m = b;
else
m= c;
cout << m = endl;
a.35 b. 25 c.34 d. 31
48. What is the output of the following C++ Code for the input data 35 30 36 24
cin »a>> b>>c » d;
if (a >b| | a >c && c !- d)
m= a;
else if (b > d)
m=b
else
m = c:
cout « m « end]:
a.35 b.45 c.31 d.40
49. What is the opposite of the boolean expression: ( 1 < x && x < 100 )
a. x < 1 ;i 100 <= x I b. !( 1 < x && x < 100 1 c. Both a or b d. None
50. What would be the value of x if y is 10 and z is 4?
switch (y - z)
{
case 8: x y + z; break;
Chapter 1 to 6
case 9. x y; break;
case 10: x - z; break;
default x y • 2;
a.20 b.42 c.35 d.45
1).A memory location with some data that can be changed is called:
a) Constant b) Variable c) Named constant d) symbolic constant
2).Variables are created in:
a) RAM b) ROM c) hard disk d) Cache
3).A memory location with some data that cannot be changed is called:
a) Constant b) Variable c) Named constant d) symbolic constant
4).Which of the following is a valid character constant?
a) a b) Variable c) ‘6’ d) =
5).Which of the following operation has lowest precedence?
a) ! b) + c) = d) ==
6).Which is\or are not a valid identifier(s) in C++?
a) Hi_There b) top 40 c) &UoAnDdOwN d) both b& c
7). C++ is strongly typed language, it means that:
a) Every program must be compiled before execution
b) Every variable must be declared before it is being used
c) The variable declaration also defines the variable
d) Sufficient data types are available to manipulate each type of data
8).which is\or are not valid identifier(s) in C++?
a) my-Name b) 9littles c) X123Y d) both a&b
9). a+=b is equivalent to:
a) b+=a b) a=+b c) a=a+b d) b=b+a
10).Which is true about a variable?
a) The name and data value can both change.
b) The name can change, but the data value cannot.
Chapter 1 to 6
c) The name cannot change, but the data value can be.
d) The name and data value both cannot changed.
11) Which is NOT a rule for naming variables?
a) Use a descriptive name for the variable.
b) Start the name of a variable with a letter.
c) Use nothing but letters, digits, or the underscore character.
d) All of above
12) Variable and constant names cannot contain a(n):
a) Number b) Underscore c) letter d) period
13) Variable name cannot being with a(n):
a) Number b) underscore c) Upper-case-letter d) lower-case-letter
14) Which of the following is NOT a valid identifier?
a) Return b) mylnt c) mylnteger d) total3
15) Which of the following are valid variable name?
a) Long b) integer c) notlongenough d) super long
16) Which term describes the kind of values that a variable can store?
a) Variable Name b) data type c) variable type d) variable size
17) which statement is true about data types?
a) Each data type has no memory requirements.
b) Each data type has different memory requirements.
c) Each data type has same memory requirements.
d) None of above
18) Which data type is used to numeric value with no decimal point?
a) Int b) char c) float d) all
19) Which is a numeric data type?
a) Floating point b) integer c) both a & b d) None
20) The number of bytes used by int data type in C++ is?
a) 2 b) 8 c) 12 d) 16
Chapter 1 to 6
21) The number of bytes used by long int data type in C++ is?
a) 2 b) 8 c) 12 d) 16
22) An integer variable can store the value:
a) -1.1 b) “123” c) 32898 d) None
23) The integer, long and short data types are known as:
a) Integer data type b) Non- Integer data type c) float data type d) Non-Numeric
data type
24) The data type that can handle decimal place is:
a) Long b) float c) char d) integer
25) The float, long-float and double data type is known as:
a) Integer data b) character data c) integral data d) real data
26) What kinds of numbers are stored in float and double data type?
a) Floating points numbers b) single and double numbers
c) Short integer numbers d) long integer numbers
27) The number of bytes used by float data type in c++ is:
a) 2 b) 8 c) 12 d) 16
28) The number of bytes used by double data type in c++ is:
a) 2 b) 8 c) 12 d) 16
29) What happens when the result of calculation exceeds the capacity of data type/
a) System error b) Logic error c) Syntax error d) Overflow
30) The exponential notation consists of:
a) Mantissa b) Exponent c) Range d) both a & b
31) The number of digits after a decimal point is called:
a) Significance b) Precision c) Range d) scope
32) Which of the following data type is used to store string value?
a) Char b) float c) string d) none
33) The name of bytes used by char data type in C++ is:
a) 2 b) 8 c) 12 d) 16
34) Which variable should be used to store the value “I want an A in this exam”
Chapter 1 to 6
a) Char b) int c) float d0 character
35) Another way to write the value 3452211903 is:
a) 3.452211903e09 b) 3.452211903e-09 c) 3.452211903×09 d) 3452211903e09
36) The constant 0.15e+6 represent the same value as:
a) 150000.0 b) 6.15 c) 0.75 d) 0.21
37) Which of the following statement declaring a variable?
a) char ch=’b’; b) char ch=’0’; c) char ch=65; d) char ch=’cc’;
38) Which of the following are required to declare a variable?
a) Continue keyword b) Variable name c) data type d) both b&c
39) Which symbol is used to separate each variable while declaring many variables one line?
a) Commas b) Colons c) pipes d) semicolons
40) Which is a valid statement for declaring a variable?
a) Int MARKS; b) int a, b,c; c) double salary; d) all
41) Which of the following data types is most appropriate for storing a name?
a) Float b) integer c) char d) None
42) The process of giving a variable its starting value is called:
A) Declaring b) initializing c) Naming d) None of these
43) Which is valid statement for initialization of a variable?
a) int n=100 b) int x=50, y=75 c) char grade=’a’; d) all
44) Which is NOT a valid statement to initialize a variable?
a) int =100; b) long population=15000; c) char n[]=”Hello word”; d) cons tint
N=100;
45) Which of the following statement is correct?
a) Float num1; num2; b) int day, night; c) int continue =5.0; d) string black =
‘white’;
46) Which of the following constant definition is correct?
a) Const float PRICE = 3500 b) const int LENGTH = 6.5;
c) Const float COST = $700.0; d) const int MY_HEIGHT = 60\12;
47) Which of the following can be used as character constant?
Chapter 1 to 6
a) Character b) Digits c) Special characters d) all
48) Which of the following are valid examples of character constant?
a) ‘A’ b) ‘9’ c) ‘&’ d) all
49) A character constant must be enclosed in:
a) Quotation marks (“) b) single quotes (‘). c) Exclamation point (!) d)
pound signs(≠)
50) What is the valid range of numbers for int type of data?
a) 0 to 256 b) -32768 to +32767 c) 65536 to +65536 d0 No specific range
51) How many bytes are occupied by the statement: float a, b:
a) 1 byte b) 4 c) 8 d) 16
52) The size of a character variable is:
a) 1 byte b) 4 c) 8 d) 16
53) An expression consists of:
a) Operation b) operand c) both a & b d) none
54) An expression can be a:
a) constant. B) Variable.
C) Combination of constants, variables, and arithmetic operations d) all
55) All of the following are valid expressions EXCEPT:
a) Sales _ Revenues b) Mpg, Gallons. C) pi * radius d) M\n
56) An assignment statement will:
a) preform a calculation b) Store the result of a calculation
c) Display the result of a calculation d) Both a & b
57) Which of the following is NOT arithmetic operations except
a) + b) _ c) % d) >
58) The modulus operators is used for:
a.Exponentiation b) multiplication
c.Division d) integer remainder
59.Which of the following operators works only with integer value?
a.% b.+ c._ d./
Chapter 1 to 6
60.The expression 10%3 has a value equal to:
a.1 b.5 c.0 d.None
61.The expression 3%5 has a value equal to:
a.3 b.5 c.0 d.None
62.The expression 0%4 has a value equal to:
a.0 b.4 c.Both a and b d.None
63.The value of the C++expression 9/5 *2 is:
a.3.6 b.0.9 c.0 d.2
64.The value of the C++ expression 5\9 *2 is:
a) 0.27 b)1.11 c) 0 d0 None
65) Given that x is a int variable and unm is an float variable containing the value 10.5,what
will x contain after execution of the following statement :
X= num + 2;
a) 12.5 b) 10.5 c) 12 d) nothing; a compile-time error occurs
66) Given that x is a float variable containing the value of 80.9 and num is an int variable, what
will num contain after execution of the statement;
Num = x+ 2.9;
a) 33.8 b) 84.0 c) 83 d) 83.0
67) The value of the c++ expression 13 +21% 4-2 is :
a) 0 b) 12 c) 16 d) 14
68) given that x is a float variable and num is an int variable containing the value 38,what will x
contain after execution of the following statement:
X= num \ 4+3.0;
a) 12.5 b) 13 c) 12 d) 12 .0
69. Assume that we have the following variable definitions in a program:
int a = 11, b = 4,c=10, d = 2; What will be the value computed for the expression (a%b+c-d-3)?
a). 6 b)30 c) 33 d) 7
70. If originally x = 5, y = 4, and z = 2, what is the value of the following expression?
y" (x + y)%3/z+10
a. 10
b.13
Chapter 1 to 6
c.9
d.8
71) What is the output of the following code fragments?
double x x=3,0 / 4,0 + 3+2/5;
a. 3,75
b. 4.75
c. 2.75
d) 3.57
72. What is the value of the following expression? (20.0 * (975)) + 32.0
a. 52.0
b. 54.0
c. 51.0
d.50
73. What is the value of the following expression? (20.0" (19/5.0)) + 32.0
a. 68.0
b. 67.0
c. 78.0
d. 88,0
74. Which assignment statement can be used to store letter A in the char variable some Char?
a. some Char="A";
b. some Char= 'A'
c. some Char=A:
d. a and c
75. Which of the following operators is used to assign a value to a variable?
a) > b) + c)= d) *
76. Which of the following is correct syntax for writing an assignment statement?
a. Variable = right side b. Constant - right side
c. Constant = variable d).none
77. The left side of an assignment statement holds:
a.A Variable.
b. Constant.
c. Expression.
d. Both a and
78. The right side of an assignment statement holds:
a. A variable b. An expression c. Both a and b d) none of these
79. Which of the following is valid assignment statement?
a. a-100;
b. c-a + b;
C.X=c-d + 10
d. All of these
80. Which of the following operators works with one operand?
a. Unary b. Binary
c. Ternary d. None
81) Which of the following operators works with two operands?
Chapter 1 to 6
a. Unary b. Binary
c. Ternary d. None
82. Which of the following statements assigns a value to many variables?
a. Compound assignment b. L value. c. K value d. Input statement
83. The statement I += 3 has the same effect as:
a. I=1+3. B) I=3
c. 1-3=1. d. 13. 54.
84) Which of the following operator is used to increase the value of a variable?
a) ++ b) +- c)>> d. None
85. Which of the following operator is used to decrease the value of a variable?
a) -- b) -+- c)<< d. None
86. Which choice has the highest order of precedence when computing an expression?
a) () b) * c) \ d) +
87. If x is int and y is float, what promotion will occur in the expression: y = 5.0 + x ;
a. float to int b. int to float
c. float to double d. No promotion
88. What is the value of x after the following statements? -
int x, y, z
y = 10; z =3; x= y *z+3;
a) 12 b) 60 c) 30 d) 33
What is the value of x after the following statements?
intx=0; x=x+ 30
a. 0 b. 30 c. 33 d) none
90. What is the value of x after the following statements?
floatx x = 13/4
a. 3.75 b. 4.0 c) 3.0 d. 60
91. What is the value of x after the following statements?
Int x; X = 15/4:
a. 15 b.3 c) 4 d.)3.75
92. What is the value of x after the following statements?
Intx;
x = 17%4;
a. 15 b. 4 c.1 d. 3.75
93. What is the value of the expression? ((1+)/(33)-(3+6))
a) -8 b. 9 c. 12 d) 16
94. What is the value of the following expression? ((5+1)((2+2+2)/2))
a) 2 b.6 c. 12 d.9
95. What is the value of the following expression? (1*2*3*4+5)
Chapter 1 to 6
a. 29 b. 30 c.33 d . 40
96. What is the value variable Result after the following code has been executed?
int result; Result=14-4"6+12/6;
a. 12 b. 2 c. -8 d. 62
97. What is the name for a word that has a specific meaning in C++?
. a Keywords b. Comments c Token d. Operators
98. Another name for keywords is:
a. Reserved words b. Special words c Comments d. None
99. What is the output of the following code fragments?
int a =5, b = 3,c = 2, d = 2:
cout << ++a/3-cd << endl;
a) -2 b) -1 c) 4 d)-4
100. What is the results value and its type of the expression? 113 - 35/(11 % 4)
al: 22 b. 32 c 11 d. 0
101. What is the results value and its type of the expression?9% 11 + 13 % 11+0% 11
a. 22 b.11 c. 12 d. 10
102. What is the results value and its type of the expression?
Hoat f= 12.0; int z = 3; (f/2-(3- ++z)) - 5
a. 22 b. 11 c.-11.0 d. 12
103. Which of the following expression will yield 0.57
a. 1 / 2.0 b. (double) 1/2 c. 1.0/2 d. All
104. -16% 4 is:
a) 0 b. 4 c. 16 d) -4
105. To add a value 1 to variable y, you write:
a.y += 1; b. y = y + 1; c.y = 1 + y; d. All
106. To add number to sum, you write:
a. sum += number; b. sum = sum +number; c. sum = Number + sum; d. both a and b
107. What is the output of the following code:
Chapter 1 to 6
double x = 3.3; int y = (int)x; cout << "x is" <x<"and y ts" <y;
a. x is 3.3 and y is 3.0 b. x is 3.0 and y is 3.0 c. x is 3.3 and y is 3 d. x is 3 and y is
3
108. We want to translate the following algebraic expression into a C++ arithmetic expres
Which of the following is the correct form?
1\c+ 1-a\1+a
a. 1/c+1-a/1 + b b.1/c+ (1 -a /1+b) c.(1 / c) + (1 -a /1+b) d. 1/c +(1-a)/(1+b)
109. Let the values of the integer variables a and b be 10 and 12 respectively. After the follos
Statement is executed, what will their values be? a += (b -= 2);
a. 20 and 10 b. 10 and 20 c10 and 12 d. 12 and 10
110. These are operators that add and subtract one from their operands.
a. ++ and -- b. Plus and minus c. Binary and unary d. None
111. Which of the following is an illegal variable name?
å: _customer_num b .jan2009 c. dayOfWeek in d. 2dGraph
112. The = operator in C++ language indicates:
a. Assignment b. Subtraction c. equality d. Negation
113. Associativity is either right to left or
a. Left to right b. Top to bottom c. Back to front d. None
114. Which of the following is used to declare a variable to store real number?
a. Integer data type b. Floating data type c Character data type d. All
1. This is a control structure that cause a statement or group of statement to repeat:
a) Decision statement
b) Loop
c) Sequential
d) None
2. One execution of a loop is known as a(n):
a) Cycle
b) Duration
c) Iteration
d) Test
3. How many types of loop structure are available in C++?
a) 4
b) 3
c) 2
d) 6
4. Which of the following loop is available in C language?
a) while
Chapter 1 to 6
b) do-while
c) for
d) all
5. A counter can be defined as:
a) The final value of loop
b) A variable that counts loop iterations
c) The initial value of a loop
d) The step value of loop
6. Where should be the loop control variable initialized?
a) Before the loop starts
b) In the first statement of the loop body
c) In the last statement of the loop body
d) Anywhere in the loop body
7. Which loop structure always executes at least once?
a) Do-while
b) For
c) While
d) None
8. which loop the condition comes before the body of the loop?
a) While loop
b) Do-while loop
c) For loop
d) B and C
9. In which loop the condition comes after the body of the loop?
a) While loop
b) Do-while loop
c) For loop
d) B and C
10. Which of the following loop is called counter loop?
a) For
b) While
c) Do-while
d) None
11. This loop is a good choice when you know how many times you want the loop to iterate
in advance of entering the loop?
a) While
b) Do-while
c) For
d) Nested
12. This statement causes a loop to terminate early?
a) Break
b) Terminate
Chapter 1 to 6
c) Exit
d) Both a and b
13. A loop within a loop is called:
a) Nested loop
b) Complex loop
c) Infinite loop
d) None
14. The loop which never ends is called:
a) Infinite loop
b) Running loop
c) Continuous loop
d) Nested loop
15. Which statement is used to move the control to the start of loop body?
a) Continue
b) Break
c) Switch
d) None
16. A special value that marks the end of a list of input date is called:
a) Terminal value
b) Sentinel value
c) Loop control value
d) Input value
17. A for statement contains three expressions: initialization, test, and_______?
a) Null
b) Validation
c) Increment/decrement
d) None
18. In a for statement, this expression is executed only once:
a) Test
b) Validation
c) Initialization
d) None
19. This statement may be used to stop a loop’s current iteration and begin next one:
a) Continue
b) Break
c) Terminate
d) None
20. This means to increase a value by one:
a) Modulus
b) Increment
c) Decrement
d) None
Chapter 1 to 6
21. If you want a user to enter exactly 20 values, which loop would be the best to use?
a) While
b) Do-while
c) For
d) Infinite
22. While loop is also called:
a) Conditional loop
b) Wend loop
c) Counter loop
d) None
23. Semicolon is placed at the end of condition in:
a) While loop
b) Do-while loop
c) For loop
d) All
24. Which is a loop statement?
a) If
b) If-else
c) Switch
d) None
25. With respect to the loop in the following main function, what is missing?
Void main()
{
Int loopCount;
while (loopCount ¿ 5 )
{
cout¿ Hi ;
loopCount++;
}
return 0;
}
a) The initialization of the loop control variable
b) The testing of the loop control variable
c) The incrementation of the loop control variable
d) Nothing is missing
26. What is the output of the following code?
Int n=4;
Do
{
Chapter 1 to 6
n = n*3;
}
while(n¿ 100 );
a) 108
b) 110
c) 107
d) 100
27. What is the output of the following code?
Int n=8;
for(int i=1; i¿n*3; i++)
n++;
a) Infinite loop
b) 9
c) 12
d) 16
28. What is the output of the following code?
Int n=4;
for(int i=n; i¿0; i--)
n-=i;
a) -6
b) 5
c) -7
d) -5
29. What is the output of the following code?
Int n=4;
While (n¿ 20)
If (n%2)
n = n-1;
else
n = n+3;
a) 21
b) 20
c) 19
d) 22
30. What is the output of the following code?
Int x= -1, y= 0;
while(x ¿3)
{
y = y +2;
x = x + 1;
}
cout¿ y;
Chapter 1 to 6
a) 10
b) 11
c) 9
d) 8
31. What is the output of the following code?
Int n= 0;
for(int m = 0; m¿ 10; m++){
n +=m++;
}
Cout ¿ n ¿ end1;
a) 20
b) 21
c) 22
d) 18
32. How many time the following code prints “ OPP Using C++”?
Int count = 0;
While (count ¿ 10)
{
cout¿ “OPP Using C++”;
count++;
}
a) 9
b) 10
c) 0
d) 11
33. How many time the following code prints “ OPP Using C++”?
Int count = 0;
While(count++¿ 10 )
{
cout¿ “OPP Using C++”;
}
a) 12
b) 10
c) 9
d) 0
34. How many time the following code prints “ OPP Using C++”?
Int count = 0;
do
{
cout¿ “OPP Using C++”;
} while (count++¿ 10);
Chapter 1 to 6
a) 11
b) 12
c) 9
d) 13
35. What is the value of variable s after the following loop terminates?
Int s = 0;
Int n = 0;
Do
{
n++;
s+= n;
if (s ¿4) break;
}
while (n ¿5);
a) 6
b) 5
c) -6
d) 0
36. What is the value of variable s after the following loop terminates?
Int s = 0;
Int n = 0;
do
{
n++;
s+= n;
if (s ¿4) continue;
}
while (n ¿5);
a) 15
b) 14
c) 16
d) 18
Chapter 1 to 6
MULTIPLE CHOICE
1. Variable that holds a large group of similar type of data is called:
a. Constant
b. Scalar value
c. Array
d. Multiple variable
2. An array:
a. Always begins at index 0
b. Of two dimensions can be accessed in the following form: x [row,col]
c. Is a contiguous allocation of memory made up of elements
d. Both a and c
3. Which of the following statements are true?
a. Every element in an array has the same type
b. The array size is fixed after it is created
c. The array size used to declare an array must be a constant expression
d. All
4. An array with no elements is:
a. Illegal in c++
b. Legal in c++
c. None
5. Which of the following is not a simple data type?
a. Int
b. Array
c. Float
d. Char
6. Each element of array has its own:
a. Array
b. Index
c. Upper bound
d. Lower limit
7. The index of first element of an array is always:
a. 0
b. 2
c. 4
d. 1
8. What is the representation of the third element in an array called n?
a. n[2]
b. n[3]
c. n[1]
Chapter 1 to 6
d. n[4]
9. What is the correct term for n [99]?
a. Array variable
b. Indexed variable
c. Both a and b
10. Each element in array has:
a. Similar index
b. Unique index
c. Both a and b
11. Which of the following declares an array of 10elements and assigns the value 3.2 to the
first element?
a. Float n[9]; n[0]=3.2;
b. Float n[9]; n[1]=3.2;
c. Float numbers [10]; n[0]-3.2;
d. Float n[10]; n[1]=3.2;
12. How many elements are the array?
a. 5
b. 6
c. 4
d. 0
13. Which line of code will declare an array and initialize it?
a. Int a[6] = (4,7,8,2,9,5);
b. Int a [6] (4,7,8,2,9,5);
c. Int a [6] = (4,7,8,2,9,5);
d. Int a [6] (4,7,8,2,9,5);
14. In the statement:
List [4]=3.3;
The value 4 indicates:
a. Size of array
b. Array Element
c. Subscript
d. Variable
15. To access an array element, use the array name and the element’s
a. Name
b. Value
c. Data type
d. Subscript
16. Which of the following is valid C++ array definition?
a. Viod n[5];
b. Int arr[20];
c. Int arr[0];
d. None
Chapter 1 to 6
17. A two-dimensional array can be viewed as:
a. Arguments,parameters
b. Increment,decrement
c. Rows,columns
18. Given the following declaration, where is 77 stored in the n array?
Int n[ ]=[83,62,77,97];
a. N[0]
b. N[1]
c. N[2]
d. N[4]
19. An array can easily be stepped through by using a:
a. Reference variable
b. Null value
c. For loop
d. None
20. What is the output of the following code?
Int main()
{
Int x [5];
Int i;
For (i=0;i<5;i++)
X[1]=i;
Count<<x[i]<<**;
}
a. 0.1234
b. 4
c. 0
d. None
21. Assume int t[] = {1,2,3,4}. What is t[4]?
a. {}
b. 3
c. 4
d. Accessing t[4] may result in runtime error
22. An array that will hold 5 names with 20characters in the name would be declared using
which statement?
a. Char names [5][20];
b. Char names[20][5];
c. Char names[21][5];
d. Char names[5][21];
23. Which of the following statements is valid?
a. Int i[]={3,4,3,2};
b. Int i[4]={3,4,3,2};
c. Double d [30];
Chapter 1 to 6
d. all
24. When an array is sorted from highest to lowest, it tis said to be in:
a. Ascending order
b. Descending order
c. Forward order
d. Reverse order
25. Which of the following is adequate for searching through small arrays?
a. Linear search
b. Binary search
c. Bubble sort
d. None
26. How many elements does the following array have?
Int n[1000];
a. 1000
b. 998
c. 0
d. 999
27. Which of the following correctly declare an array that can hold up to 3 rows of 5 columns
of doubles?
a. Double array [3];[5];
b. Int array [3](int [5]);
c. Double array[3][5];
d. Double array [3,5];
28. What is the output of the following C++ code?
Int n[] {56,90,86,97,120};
Count << n{3} <<endl;
a. 97
b. 98
c. 99
d. 90
29. What is the output of the following C++ code?
Int n[5];
For (int i=1;i<5;i++)
N{I – 1} - I + 1;
For (int I = 0; I < 3;i++)
Count << n[i];
a. 234
b. 240
c. 334
d. 221
Chapter 1 to 6
30. What is the output of the following C++ code?
Int n[4]={87,63};
Count << n{3} << endl;
a. 0
b. -1
c. 1
d. 3