COMPUTER PROGRAMMING (C++) PAST QUESTIONS WITH ANSWERS

 


 This post contains a question bank in the form of true/false, fill in the blanks and MCQ questions on the topic of Fundamentals Of Computer Programming (C++).


COMPUTER PROGRAMMING (C++) PAST QUESTIONS AND LIKELY EXAMINATIONS QUESTIONS WITH ANSWERS

 

1. The identity element in multiplication is 0:

a. True

b. False

                        ANSWER:  B

2. Which one of the following is a keyword?:

a. Jump

b. Switch

c. Size

d. Key

                        ANSWER:  B

3. Float precision is larger than double:

a. False

b. True

                        ANSWER:  A

 

4. While iteration is not the same as while loop:

a. True

b. False

                        ANSWER:  B

 

5. What are the escape sequences?:

a. Set of characters that are avoided in cout statements

b. Set of characters that are used in the name of the main function of the program

c. Set of characters that whose use are avoided in C++ programs

d. Set of characters that convey special meaning in a program

                        ANSWER:  D

 

6. Integer values are stored in ___ bit format in binary form:

a. 16

b. 64

c. 8

d. 32

                        ANSWER:  A

7. while iteration is not a repetitive activity:

a. False

b. True

                        ANSWER:  A

 

8. pre and post increment performs the same function:

a. False

b. True

                        ANSWER:  A

 

9. The main function has no parenthesis:

a. True

b. False

                        ANSWER:  B

 

10. Escape characters are not recognize in c plus plus:

a. True

b. False

                        ANSWER:  B

11. What is a constant that contains a single character enclosed within single quotes?:

a. Fixed

b. Numeric

c. Character

d. Floating point

                        ANSWER:  C

 

12. Float and double are related to ____ data type.:

a. Floating

b. Fixed

c. Integral

d. Void

                        ANSWER:  A

13. Which one is not a correct variable type in C++?

 a. real

b. float

c. int

d. double

                        ANSWER:  A

14. C plus plus was not evolved from C:

a. True

b. False

                        ANSWER:  B

15. An expression A.B in C++ means ____:

a. A is member of object BB.

b. Product of A and B

c. B is member of Object A

d. None of these

                        ANSWER:  C

16. Identifiers can have spaces:

a. False

b. True

                        ANSWER:  A

17. Logical AND and Logical OR are ___ operators.:

a. Logical

b. Comma

c. Class member

d. Equality

                        ANSWER:  A

 

18. Which one of the following is a keyword?:

a. Switch

b. Key

c. Jump

d. Size

                        ANSWER:  A

19. Signed, unsigned, long and short are some of the ___:

a. Modifiers

b. Void

c. Derived data

d. Data

                        ANSWER:  A

20. When a=6, c= ++a what will be the value of c?:

 a. 9

b. 7

c. 8

d. 6

                        ANSWER:  B

 21. ___ is the smallest individual unit in a program:

a. Control

b. Variable

c. Character

d. Token

                        ANSWER:  D

22. Java and C plus plus are both procedural languages

a. True

b. False

                        ANSWER:  B

23. Who created C++?:

a. Brian Kernighan

b. Bjarne Stroustrup

c. Ken Thompson

d. Dennis Ritchie

                        ANSWER:  B

24. Floats and double perform the same function:

a. True

b. False

                        ANSWER:  B

25.  = is called:

a. Conditional Operator

b. assignment Operator

c. equal to

d. Scope Resolution Operator

                        ANSWER:  B

26. A C++ code line ends with ___

a. A Semicolon (;)

b. A Fullstop(.)

c. A Slash (/)

d. A Comma (,)

                        ANSWER:  A

27. Every statement in C plus plus must end with a semi colon:

a. False

b. True

                        ANSWER:  A

28. ____ operators have lower precedence to relational and arithmetic operators.

a. Logical

b. Conditional

c. Relational

d. Boolean

                        ANSWER:  A


29. Arrays and variables are the same:

a. False

b. True

                        ANSWER:  A

30. Every variable should be separated by ___ separator.

a. Comma

b. Dot

c. Colon

d. Semicolon

                        ANSWER:  C                

31. Explicit type conversion is accomplished in C++ with which of the following operation?

(A) explicit

(B) type_cast

(C) covert

(D) static_cast

ANSWER  :   D

32. In a computer program, which type of logic structure directs the computer to process the program instructions one after another, in the order listed in the program?

(A) variable

(B) selection

(C) repetition

(D) sequence

ANSWER  :   D

33. How many arguments can the for clause contain?

(A) 3

(B) 4

(C) 1

(D) 2

ANSWER  :   A

34. In a for statement, which argument or arguments are required?

(A) initialization and condition

(B) initialization and update

(C) condition

(D) initialization

ANSWER  :   D

 

35. Float and double are related to ______ data type.

(A) integral

(B) void

(C) Fixed

(D) Floating

ANSWER  :   D

36. In a pseudocode algorithm, what part of language should each instruction begin with?

(A) verb

(B) noun

(C) adverb

(D) article

ANSWER  :   A

37. In a repetition structure, what is the requirement for repeating the instructions called?

(A) infinite loop

(B) sentinel value

(C) exit condition

(D) double quotes

ANSWER  :   A

38. Given the code below beginning a switch statement, what type of data would be required for the value in each case clause?

char letter = ‘    ‘;

cout<<”Enter a letter:  ”;

cin>> letter;

switch (letter)

{

………………..

 

(A) char

(B) bool

(C) double

(D) int

ANSWER  :    A

39. If the is no default clause in a switch statement and no match is found, what happens?

(A) the instruction after the closing brace is executed

(B) the computer loops to the beginning of the switch statement

(C) an error code is generated

(D) the program execution is terminated

ANSWER  :   D*

40. In a pretest loop, what should you include in the loop body to ensure that there is a way to enter the sentinel value after the loop body instructions are processed the first time?

(A) trip value

(B) update read

(C) trailer value

(D) priming read

ANSWER  :   B

41. How many different states do the switches in machine language have?

(A) 8

(B) 2

(C) 16

(D) 1

ANSWER  :   B

42. In a flowchart, what does a diamond that has more than two flow lines represent?

(A) single-alternative selection structure

(B) optional selection structure

(C) extended selection structure

(D) dual-alternative selection structure

ANSWER  :    C

43. For program to use the setprecision stream manipulator, it must include which file?

(A)

(B)

(C)

(D)

ANSWER  :   header file iomanip

44. How many times will the instruction in the loop body of the following code be processed?

int x = 3;

do

{

X++;

} while (x <= 3);

(A) 2

 (B) infinite

(C) 0

(D) 1

ANSWER  :   D

44. If the default clause is the last clause in a switch statement, what statement is required after the default clause?

(A) break statement

(B) an exit statement

(C) case statement

(D) no statement is required

ANSWER  :   D

45. In a repetition structure, what is the requirement for not repeating the instructions called?

(A) sentinel value

(B) loop exit condition

(C) break condition

(D) looping condition

ANSWER  :   B

46. If the value’s data type does not match the memory location’s data type, what process does the computer use to convert the value to fit the memory location?

(A) truncation

(B) implicit type conversion

(C) explicit type conversion

(D) rounding

ANSWER  :      B

47. In a pretest loop, what initializes the loop condition by providing its first value?

(A) update read

 (B) priming read

(C) none of the above

(D) sentinel value

ANSWER  :   A

 48. To be sure an algorithm works correctly, you should desk-check it several times using which of the following? Select one:

(A) valid data only

(B) invalid data only if valid data works correctly

(C)  both valid and invalid data

(D) invalid data only

ANSWER  :   C

 

49. Which of the following is another name for a sentinel value? Select one:

(A) looping value

(B) priming value

(C) exiting value

(D)  trip value

ANSWER  :   D

 

50. What is the second step in the problem-solving process? Select one:

(A) code the algorithm into a program

(B) analyze the problem

(C) write the documentation

(D) plan the algorithm

ANSWER  :  C

 

51. The name of a memory location in C++ can begin with a letter or a number. Select one:

(A) True

(B) False

ANSWER  :    B

52. What type of value is used to update a counter? Select one:

(A) negative

(B) constant

(C) variable

(D) floating point

ANSWER  :  B

 

53. In an if statement, the programmer must supply the condition that the computer needs to evaluate before further processing can occur. The condition must be which type of expression? Select one:

(A) arithmetic

(B)  data

(C) Boolean

(D) comparison

ANSWER  :   C

 

54. The instructions in a posttest loop will always be executed at least once, but the instructions in a pretest loop may never be processed. Select one:

(A) True

(B)  False

ANSWER  :   A

 

55. Comparison operators are used to compare two values with differing data types. Select one:

(A) True

(B) False

ANSWER  :   B

 

56. A loop whose instructions are processed indefinitely is referred to as which of the following? Select one:

(A) while statement

(B) infinite loop

(C) terminal loop

(D) for statement

ANSWER  :   B

 

57. The execution of a C++ program begins with the main function. Select one:

(A) True

(B) False

ANSWER  :   A

58. When you break one of the programming language rules it is a logic error

(A) True

(B) False

ANSWER  :   B

59. The update read is often an exact copy of the priming read

(A) True

(B) False

ANSWER  :   A

60. The selection structure is also referred to as an iteration

(A) True

(B) False

ANSWER  :  B  

61. With the do while statement, the loop body may never be executed

(A) True

(B) False

ANSWER  B:  

62. The processing of locating and correcting the errors in a program is called debugging.

(A) True

(B) False

ANSWER  :  A

63. The while loop is an example of a posttest loop

(A) True

(B) False

ANSWER   :  A  

64. The remainder operator is used to divide two integers and results in the remainder of the division

(A) True

(B) False

ANSWER  : B 

65. With short-circuit evaluation, each sub-condition is independent of any other sub-condition

(A) True

(B) False

ANSWER  :   B

66. When naming a memory location in C++, names are not case sensitive.

(A) True

(B) False

ANSWER  :  B

67. The selection structure is used when a programmer wants to repeatedly process one or more program instructions

(A) True

(B) False

ANSWER  :  A

68. You need to consider all information when analyzing a problem, even if it is unnecessary to the solution

(A) True

(B) False

ANSWER  :   B

69. Using an unnecessary selection structure is one of the mistakes that causes logic errors in selection structures.

(A) True

(B) False

ANSWER  :   A

70. The stringdata type is considered a primitive data type

(A) True

(B) False

ANSWER  :   B

71. The update read initializes the loop condition by providing its first value.

(A) True

(B) False

ANSWER  :    B

72. When you decrement a value stored in an accumulator, you add a number to it.

(A) True

(B) False

ANSWER  :   A

73. To ensure the algorithm is working correctly, a programmer should desk-check it using both valid and invalid data.

(A) True

(B) False

ANSWER  :   A

74. When using flowcharts, the processing symbol is represented by a rectangle

(A) True

(B) False

ANSWER  :   A

75. There is one universal machine language used by computers

(A) True

(B) False

ANSWER  :   A

76. When using flowcharts, the input output is represented by an oval

(A) True

(B) False

ANSWER  :   B

77. The switch clause can always be used in replace of a multiple-alternative selection structure.

(A) True

(B) False

ANSWER  : B   

78. With nested repletion structures, both loops must be the same type (example both must be pretest loops, or both must be posttest loops)

(A) True

(B) False

ANSWER  :   B

79. Without a specialized instruction, in order to swap the contents of two variables a third variable is needed

(A) True

(B) False

ANSWER  :   A

80. The value of a named constant is allowed to change during runtime

(A) True

(B) False

ANSWER  :   B

81. Values that are used to end loops are referred to as sentinel value.

(A) True

(B) False

ANSWER  :   A

82. When used with the cout object, the endl stream manipulator advances the cursor to the next line on the computer screen.

(A) True

(B) False

ANSWER  :   A

83. The repetition structure has a true path and a false path

(A) True

(B) False

ANSWER  :   A

84. There are two digits in the machine language system

(A) True

(B) False

ANSWER  :   A

85. You need to use both pseudocode and flowchart when planning an algorithm

(A) True

(B) False

ANSWER  :   A

86. Two different selection structures in sequence (one after another) are called a nested selection structure.

(A) True

(B) False

ANSWER  :   B

87. A pretest loop and posttest loop produce the same results; they just use different methods. Select one:

True

False

ANSWER  :   B

88. A common error made when writing selection structures is to use a compound condition in the outer selection structure when a nested selection structure is needed. Select one:

True

False

ANSWER  :   A

 

 89. A common error made when writing selection structures is to reverse the decisions made by the outer and nested structures. Select one:

True

False

ANSWER  :   A

 

90. A pretest loop and posttest loop produce the same results; they just use different methods. Select one:

True

False

ANSWER  :   B

 

91. A common error made when writing selection structures is to reverse the decisions made by the outer and nested structures. Select one:

True

False

ANSWER  :   A

 

92. A stream is defined in C++ as a sequence of numeric values. Select one:

True

False

ANSWER  :   B

 

93. A common error made when writing selection structures is to reverse the decisions made by the outer and nested structures. Select one:

True

False

ANSWER  :   A

 

94. Within a switch statement, the _____ clause can contain one or more statements to be executed when the selectorExpression does not match any of the _____ clauses. Select one:

a. if, else

b. break, case

c. case, default

d. default, case

ANSWER  :   D

 

95. A processing item in an IPO chart represents an intermediate value that the algorithm uses when processing the input into the output. Select one:

True

False

ANSWER  :   A

 

96. A common error made when writing selection structures is to use a compound condition in the outer selection structure when a nested selection structure is needed. Select one:

True

False

ANSWER  :   A

 

97. A keyword is a word that has special meaning in the programming language you are using. Select one:

True

False

ANSWER  :   A

 

98. With what type of program does the programmer focus on structures that represent screen elements such as check boxes and buttons or structures that represent real world items such as an employee or time card? Select one:

a. assembly language

b. procedure-oriented

c. object-oriented

d. machine language

ANSWER  :   C

 

99. With a do while statement, the looping condition indicates the requirement for _____ the loop body instructions. Select one:

a. printing

b. reversing

c. exiting

d. repeating

ANSWER  :   D

 

100. Which structure do you use every time you drive your car and approach an intersection? Select one:

a. sequence

b. selection

c. iteration

d. repetition

ANSWER  :   B

 

101. Which two C++ statements can be used to code pretest loops? Select one:

a. if, while

b. for, switch

c. switch, if

d. for, while

ANSWER  :    D

 

102. Which stream manipulator can be used to advance the cursor to the next line on the computer screen? Select one:

a. cin

b. endline

c. cout

d. endl

ANSWER  :   D

 

103. With whom should a programmer have extensive interaction before converting a solution to a problem into a computer program? Select one:

a. user

b. language developer

c. compiler vendor

d. system engineer

ANSWER  :   A

 

104. Which symbol is used in C++ for the logical And operator? Select one:

a. &&

b. %

c. ||

d. @

ANSWER  :   A

 

105. Which type of structure do all programs use? Select one:

a. selection

b. sequence

c. repetition

d. variable

ANSWER  :   B

 

106. A stream is defined in C++ as a sequence of numeric values. Select one:

True

False

ANSWER  :   B

 

107. A pretest loop and posttest loop produce the same results; they just use different methods. Select one:

True

False

ANSWER  :   B

 

108. A compiler translates instructions line by line as the program is running. Select one:

True

False

ANSWER  :   B

 

109. A variable is a memory location whose value can change during runtime. Select one:

True

False

ANSWER  :   A

 

110. Which symbol in a flowchart is known as the decision symbol? Select one:

a. diamond

b. parallelogram

c. oval

d. rectangle

ANSWER  :   A

 

111. With a do while statement, the looping condition indicates the requirement for the loop body instructions. Select one:

a. repeating

b. reversing

c. exiting

d. printing

ANSWER  :   A

 

112. Which type of structure makes a decision based on one or more conditions? Select one:

a. looping

b. selection

c. Iteration

d. question

ANSWER  :   B

113. The value 29 is considered a double

(A) True

(B) False

ANSWER  :   B

 

114. Examine the following code. What type of error do you find and what is the correct line of code if the goal of the program is to calculate a grade point average from the point values of three classes?

int gpa;

int numclassess = 3;

int class1 =4;

int class2 = 2;

int class3 = 3;

gpa = (class1 + class2) + class3/numclasses;

(A) syntax error, gpa += (class1 + class2) + class3/numclasses;

(B) logic error, gpa = class1 + class2 + (c;ass3/numclasses);

(C) logic error, gpa = (class1 + class2 + class3)/numclasses;

(D) syntax error, gpa = class1++  class2++  class3++ / numclasses;

ANSWER  :   C

115. Comparison operators evaluate to what type of value?

(A) real

(B)  character

(C) boolean

(D) integer

ANSWER  :   C

116. The switch clause can always be used in replace of a multiple-alternative selection structure.

(A) True

(B) False

ANSWER  :   B

117. The selection structure is used when a programmer wants to repeatedly process one or more program instructions.

(A) True

(B) False

 

ANSWER  :   A

118. AND and OR are the two most commonly used example of which type of operator?

(A) comparison

(B) boolean

(C) assignment

(D) relational

 

ANSWER  :   D

119. Two different selection structures in sequence (one after another) are called a nested selection structure.

(A) True

(B) False

 

ANSWER  :   B

120. There are two digits in the machine language system.

(A) True

(B) False

ANSWER  :   A

121. By default in C++, smaller real numbers with a decimal place (those containing six or fewer digits to the left of the decimal displayed in exponential notation.

(A) True

(B) False

ANSWER  :   B

122. The data type of the value in a case clause within a switch statement must be compatible with the data type of the following?

(A) defaltExpression

(B) if statement

(C) selectorExpression

(D) else clause

 

ANSWER  :   C

123. In a computer program, which type of logic structure directs the computer to process the program instructions one after another, in the order listed in the program?

(A) sequence

(B) selection

(C) variable

(D) repetition

 

ANSWER  :   A

 

124. Selection structures that contain instruction on both the true and false path are referred to as which of the following?

(A) dual-alternative

(B) two path

(C) single-alternative

(D) none of the above

 

ANSWER  :   A

125. Examine the following switch statement. What is needed to make a valid switch statement?

Switch

{

case 10:

          cout<< “The answer is 10. ”;

          break;

case 20:

case 30:

          case<< “The answer is 20 or 30. ” ;

          break;

          default:

          cout << “The answer is none of them.  ”;

          break;

case 40;

          cout<< “The answer is 40. ”;

}

(A) a selectorExpression is need

(B) a break statement is needed after case 40:

(C) a statement block is needed after the case 20: clause

(D) the default clause must be moved to the end.

 

ANSWER  :   A

126. If the default clause is the last clause in a switch statement, what statement is required after the default clause?

(A) no statement is required

(B) a case statement

(C) an exit statement

(D) a break statement

 

ANSWER  :   A

 

127. The remainder operator is used to divide two integers and results in the remainder of the division.

(A) True

(B) False

 

ANSWER  :   B

128. Assembly language requires a programmer to enter the program using 1s and 0s.

(A) True

(B) False

 

ANSWER  :   B

 

129. An example of an instruction written in machine language would be ____________

(A) 0000 0101 1100 000

(B) ADD bx, ax

(C) sum = num1 – numb2

(D) repeat 5 times

ANSWER  :   A

130. Although not required, it is good programming practice to mark the end of the loop with a(n) ______

(A) semicolon

(B) comment

(C) cout statement

(D) end statement

 

ANSWER  :   B

131. To insert a comment into a C++ program you begin the line with which of the following?

(A) \\

(B) **

(C) ||

(D) //

 

ANSWER  :     D

132. Comparison operators are used to compare two values with differing data types.

(A) True

(B) False

 

ANSWER  :     B

 

133. The output of the following code is sumX: 3 and sumY: 2

int sumX = 0;

int sumY = 0;

do

{

sumX++;

sumY++;

sumX+ = sumY;

} while(sumX<2);

Cout<< “sumX: ” <<sumX<<”sumY: ”<<sumY;

(A) True

(B) False

 

ANSWER  :   B

134. With whom should a programmer have extensive interaction before converting a solution to a problem into a computer program?

(A) language developer

(B) compiler vendor

(C) user

(D) system engineer

 

ANSWER  :   C

135. After coding a program, the programmer should perform which task before releasing it to user?

(A) write a user manual

(B) assemble the program with an interpreter

(C) ask the user to approve the machine code

(D) test the program with sample data

 

ANSWER  :   D

136. Mnemonics are a special number system used by assembly languages.

(A) True

(B) False

 

ANSWER  :   B

137. When name a memory location in C++, name are not case sensitive.

(A) True

(B) False

 

ANSWER  :   B

138. Another name for the selection structure is the decision structure

(A) True

(B) False

 

ANSWER  :   A

 

139. The execution of a C++ program begins with the main function

(A) True

(B) False

 

ANSWER  :   A

140. The main reason why high-level languages were a vast improvement over machine and assembly languages is because they allow the programmer to use instructions that more closely resemble the English language.

(A) True

(B) False

 

ANSWER  :   A

141. In C++, the float and double variable data types are used to store real number

(A) True

(B) False

 

ANSWER  :   A





OTHER LIKELY EXAMINATION QUESTIONS AND ANSWERS (PART 1).

 1. C++ was developed by ___

(A) Thomas Kushz

(B) John Kemney

(C) Bjarne Stroutstrup

(D) James Goling

ANSWER:  C

2. Which one of the following is a keyword?

(A) Size

(B) Key

(C) Jump

(D) Switch

ANSWER:  D

3. ____ is the smallest individual unit in a program.

(A) Variable

(B) Control

(C) Character

(D) Token

ANSWER:  D

4. What is a constant that contains a single character enclosed within single quotes?

(A) Character

(B) Numeric

(C) Fixed

(D) Floating point

ANSWER:  A

5. The modulus operator uses ___ character.

(A) +

(B) *

(C) /

(D) %

ANSWER:  D

 

6. Every variable should be separated by ___ separator.

(A) Dot

(B) Colon

(C) Comma

(D) Semicolon

ANSWER:  C

7. Auto, static, extern and register are called as ___

(A) Static

(B) Register

(C) Auto

(D) Storage specifier

ANSWER:  D

8. How many storage specifies are there in a C++?

(A) 2

(B) 3

(C) 4

(D) 5

ANSWER:  C

9. Signed, unsigned, long and short are some of the ___

(A) Void

(B) Data

(C) Derived data

(D) Modifiers

ANSWER:  D

10. Logical AND (&&) and Logical OR (||) are ___ operators.

(A) Logical

(B) Equality

(C) Class member

(D) Comma

ANSWER:  A

 

11. ____ operators have lower precedence to relational and arithmetic operators.

(A) Conditional

(B) Boolean

(C) Logical

(D) Relational

ANSWER:  D

12. How many C++ data types are broadly classified?

(A) 2

(B) 3

(C) 4

(D) 5

ANSWER:  B

13. Float and double are related to ____ data type.

(A) Void

(B) Floating

(C) Fixed

(D) Integral

ANSWER:  B

14. Variable names must begin with ___

(A) #

(B) $

(C) Number

(D) Letter

ANSWER:  D

15. Integer values are stored in ___ bit format in binary form.

(A) 8

(B) 16

(C) 32

(D) 64

ANSWER:  B

16. Which of the following is not a C++ keyword?

(A) This

(B) New

(C) Cont

(D) If

ANSWER:  C

17. ____ is a variable that holds a memory address.

(A) Long double

(B) Float

(C) Char

(D) Pointer

ANSWER:  D

18. Addressing is done using ___ number system.

(A) Decimal

(B) Hexadecimal

(C) Octal

(D) Binary

ANSWER:  B

19. Which one of the following is a membership operator?

(A) !

(B) &

(C) ::

(D) .

ANSWER:  D

20. ____ Operator requires two operands.

(A) Logical

(B) Binary

(C) Unary

(D) Ternary

ANSWER:  B

 

21. Auto variables get undefined values known as ___

(A) Garbage

(B) Auto

(C) Register

(D) Static

ANSWER:  A

22. ____ storage class variables are defined in another program.

(A) Register

(B) Auto

(C) Extern

(D) Static

ANSWER:  C

23.____ Type is used to declare a generic pointer in C++.

(A) Int

(B) Void

(C) Static

(D) Float

ANSWER:  B

24. Which is a conditional operator?

(A) @

(B) >

(C) <

(D) ?:

ANSWER:  D

25. Built in Data type is also called as ___ data type.

(A) Fundamental

(B) Secondary

(C) Void

(D) Integer

ANSWER:  A

26. Additive, Multiplicative, shift, Bitwise logical and assignment operators is ____ operator.

(A) Conditional

(B) Relational

(C) Unary

(D) Binary

ANSWER:  D

27. Binary plus (+) and Binary minus (-) are ___ operator.

(A) Additive

(B) Multiplicative

(C) Shift

(D) Bitwise

ANSWER:  A

28. What is the length of double data type?

(A) 8

(B) 16

(C) 32

(D) 64

ANSWER:  D

29. Which operator requires three operands?

(A) Unary

(B) Binary

(C) Ternary

(D) Bitwise

ANSWER:  D

30. What are bitwise operators?

(A) &

(B) !

(C) ^

(D) All (a, b and c)

ANSWER:  D

31. The constant that should not have fractional part is ___

(A) Float

(B) Double

(C) Integer

(D) Exponent

ANSWER:  C

32. What is the other name for variable?

(A) While

(B) Visual

(C) Identifier

(D) Constant

ANSWER:  C

33. ____ constant is a signed real number.

(A) Char

(B) String

(C) Integer

(D) Floating point

ANSWER:  D

34. How many operators are classified in C++?

(A) 11

(B) 13

(C) 14

(D) 15

ANSWER:  B

35. ____ is the C increment Operator in C++.

(A) ++

(B) +*

(C) *+

(D) --

ANSWER:  A

36. Rick Mascitti coined the name ___

(A) Visual BASIC

(B) COBOL

(C) C++

(D) BASIC

ANSWER:  C

37. ____ is a sequence of characters surrounded by double quotes.

(A) Constant

(B) Numeric

(C) Character

(D) String literal

ANSWER:  D

38. How many fundamental data types are there in C++?

(A) 1

(B) 2

(C) 3

(D) 4

ANSWER:  C

39. ____ is an operator which returns the memory size requirements in terms of bytes.

(A) Double

(B) Size

(C) Size of

(D) Long

ANSWER:  C

40. What are shift operators?

(A) << 

(B) >> 

(C) > 

(D) Both (a) and (b)

ANSWER:  D

41. ____ class is another qualifier that can be added to a variable declaration.

(A) Register

(B) Static

(C) Sub

(D) Storage

ANSWER:  D

42. ____ storage class global variable known to all functions in the current program.

(A) Register

(B) Extern

(C) Static

(D) Auto

ANSWER:  B

43. The address number starts at ___

(A) 1

(B) 2

(C) 3

(D) Null

ANSWER:  D

44. _____ are the kind of data that variables hold in a programming language.

(A) Conditional type

(B) Constant type

(C) Variable type

(D) Data types

ANSWER:  D

45. The operands and the operators are grouped in a specific logical way of evaluation is called ____

(A) Assignment

(B) Association

(C) Arithmetic

(D) Class

ANSWER:  B

45. Which one gives special meaning to the language compiler?

(A) Constant

(B) Variable

(C) Keywords

(D) Compiler

ANSWER:  C

46. Which operator requires one operand?

(A) Unary

(B) Binary

(C) Ternary

(D) Both (a) and (b)

ANSWER:  A

47. ___ data type to indicate the function does not return a value.

(A) Static

(B) Main

(C) Public

(D) Void

ANSWER:  C

48. ___  type is further divided into int and char.

(A) Float

(B) Int

(C) Char

(D) Integral

ANSWER:  D

49. The enum, unsigned int, short int and int data type’s uses ___ bits.

(A) 8

(B) 16

(C) 32

(D) 64

ANSWER:  B

50. Which of the following are good reasons to use an object oriented language?

(A) An object oriented program can be taught to correct its own errors

(B) Program statements are simpler than in procedural language

(C) We can define our own data types

(D) None of these

ANSWER:  C

51. In a class specified, data or functions and designated private are accessible

(A) Only to public members of class

(B) Only if you know the password

(C) To any function in the program

(D) To member functions of that class

ANSWER:  D

52. When a language has the capability to produce new data types, it is called

(A) Extensible

(B) Encapsulated

(C) Reprehensible

(D) None of these

ANSWER:  D

53. Keyword typed is used to declare

(A) A synonym for an existing type

(B) Absence of a type

(C) Objects that can be modified outside of a program control

(D) A member function that is defined in a subclass

ANSWER:  A

54. In C++ programming language, to write data that contains variables of type flat to an object of type of stream, which of the following should be used?

(A) Put ( )

(B) Seekg ( )

(C) Write ( )

(D) Insertion operator

ANSWER:  C

55. _____ variable of the same data type can be declared in a single declaration statement.

(A) Two

(B) Three

(C) Only one

(D) More than one

ANSWER:  D

56. The special characters like tab, backspace, line feed, null, back slash are called ____ character constant

(A) Floating

(B) String

(C) Graphic

(D) Non-graphic

ANSWER:  D

57. What type of integer starts with 0X?

(A) Decimal

(B) Binary

(C) Hexadecimal

(D) Octal

ANSWER:  C

58. The sequence of digits starting with 0 is treated as ___ constant.

(A) Penta

(B) Hexadecimal

(C) Binary

(D) Octal

ANSWER:  D

59. The body of function contains ___

(A) Return statement

(B) A variable declaration part

(C) Processing part

(D) All the above

ANSWER:  D

60. Where a condition is checked to see whether to do one or more iteration is _____

(A) Definite iteration

(B) Sequencing

(C) Indefinite iteration

(D) None of these

ANSWER:  B

61. Which one is the valid real constant?

(A) 85.46

(B) 85

(C) 0.85

(D) Both a and c

ANSWER:  D

62. ______ variables are sensitive to the data type they point to.

(A) Char

(B) Pointer

(C) Integer

(D) Float

ANSWER:  B

63. For example class boy, ____ is a user defined data type of class.

(A) Class

(B) Type

(C) Boy

(D) User

ANSWER:  C

64. When a=6, c= ++a what will be the value of c?

(A) 6

(B) 7

(C) 8

(D) 9

ANSWER:  B

65. When a=6 and c=a++ what is the value of c?

(A) 6

(B) 7

(C) 8

(D) 9

ANSWER:  A

66. The statement int A; b; is invalid because ____

(A) Variables should be separated by Comma

(B) Capital A is not allowed

(C) Only one variable should be given

(D) All of these

ANSWER:  A

67. What is a file?

(A) A file is a selection of main storage used to store data.

(B) A file is another name for floppy disk.

(C) A file is a part of a program that is used to describe what the program should do.

(D) A file is a collection of information that has been given a name and is stored in secondary memory.

ANSWER:  D

68. What is the default file extension for all Word documents?

(A) FIL

(B) DOC

(C) WRD

(D) TXT

ANSWER:  B

69. The ____ key and the ___ key can be used in combination with other keys to perform shortcuts and special tasks.

(A) Control, Alt

(B) Function, toggle

(C) Delete, Insert

(D) Caps Lock, Num Lock

ANSWER:  A

70. ____ literals are treated as array of characters.

(A) Graphic

(B) Character

(C) String

(D) Non-graphic

ANSWER:  C

71. Which one holds the values or constants in memory boxes?

(A) Variable

(B) While

(C) Goto

(D) Switch

ANSWER:  A

72. In which type of constant the Decimal numbers, integer and floating-point are related?

(A) Numeric

(B) String

(C) Char

(D) Boolean

ANSWER:  A

73. The basic types are collectively called as ___

(A) Looping

(B) Tokens

(C) Expression

(D) Variables

ANSWER:  B

74. ____ are data items whose value cannot be changed.

(A) Class

(B) Return

(C) Constants

(D) Variable

ANSWER:  C

75. Every variable will be referred by its ___

(A) Data

(B) Int

(C) Name

(D) Address

ANSWER:  D

76. Which storage class defines local variable known to the block in which they are defined?

(A) Register

(B) Auto

(C) Extern

(D) Static

ANSWER:  B

77.____ allows users to define the user defined data type identifier.

(A) Class

(B) Data

(C) Identifier

(D) Type definition

ANSWER:  D

78. What is the length of long double data type?

(A) 8

(B) 16

(C) 32

(D) 80

ANSWER:  D

79. The names beginning with an underscore are reserved for _____ variable.

(A) Globar

(B) Local

(C) Internal system

(D) External system

ANSWER:  C

80. Which punctuator is used to group a set of C++ statements?

(A) {}

(B) []

(C) ()

(D) /

ANSWER:  A

81. ____ refers to the process of changing the data type of the value stored in a variable.

(A) Type char

(B) Type int

(C) Type float

(D) Type cast

ANSWER:  D

82. ____ data types are structure, union, class and enumeration.

(A) Derived

(B) Integer

(C) Built-in

(D) User defined

ANSWER:  D

83. Which operator is used to compare numerical values?

(A) Relational

(B) Conditional

(C) Assignment

(D) Arithmetic

ANSWER:  A

84. ____ allocates memory, based on the data type of the variable.

(A) Interpreter

(B) Link

(C) Converter

(D) Compiler

ANSWER:  D

 


OTHER LIKELY EXAMINATION QUESTIONS AND ANSWERS ON C++ BASICS  (PART 2)

1. Which of the following is the correct syntax of including a user defined header files in C++?
          A) #include <userdefined.h>
          B) #include <userdefined>
          C)  #include “userdefined”
          D) #include [userdefined]

ANSWER: C


Explanation: C++ uses double quotes to include a user-defined header file. The correct syntax of including user-defined is #include “userdefinedname”.

2. Which of the following is a correct identifier in C++?

A) 7var_name
B) 7VARNAME
C) VAR_1234
D) $var_name

ANSWER: C


Explanation: The rules for writing an identifier is as follows:
i) may contain lowercase/uppercase letters, digits or underscore(_) only
ii) should start with a non-digit character
iii) should not contain any special characters like @, $, etc.

 

3. Which of the following is called address operator?

         A) *
         B) &
         C) _
         D) %

ANSWER:  B

 

 

4. Which of the following is used for comments in C++?

A) // comment
B) /* comment */
C) both // comment or /* comment */
D) // comment */

ANSWER:  C


Explanation: Both ways are used for commenting in C++ programming. // is used for single line comments and /* … */ is used for multiple line comments.

 

5. What are the actual parameters in C++?

A) Parameters with which functions are called
B) Parameters which are used in the definition of a function
C) Variables other than passed parameters in a function
D) Variables that are never used in the function

ANSWER:  A

 

 


Explanation: Actual parameters are those using which a function call is made i.e. which are actually passed in a function when that function is called.

 

6. What are the formal parameters in C++?

A) Parameters with which functions are called
B) Parameters which are used in the definition of the function
C) Variables other than passed parameters in a function
D) Variables that are never used in the function

ANSWER:  B


Explanation: Formal parameters are those which are used in the definition of a function. They are the parameters that represent the actual parameters passed and they are the one which is used inside the function.

7. Which function is used to read a single character from the console in C++?
a) cin.get(ch)
b) getline(ch)
c) read(ch)
d) scanf(ch)

ANSWER:  A


Explanation: C++ provides cin.get() function to read a single character from console whereas others are used to read either a single or multiple characters.

 

8. Which function is used to write a single character to console in C++?

A) cout.put(ch)
B) cout.putline(ch)
C) write(ch)
D) printf(ch)

ANSWER:  A


Explanation: C++ provides cout.put() function to write a single character to console whereas others are used to write either a single or multiple characters.

 

9. What are the escape sequences?

A) Set of characters that convey special meaning in a program
B) Set of characters that whose use are avoided in C++ programs
C) Set of characters that are used in the name of the main function of the program
D) Set of characters that are avoided in cout statements

ANSWER:  A


Explanation: Escape sequence is a set of characters that convey a special meaning to the program. They are used to convey a meaning which cannot be conveyed directly.

10. Which of the following escape sequence represents carriage return?

A) \r
B) \n
C) \n\r
D) \c

ANSWER:  A


Explanation: \r is used to represent carriage return which means move the cursor to the beginning of the next line.

11. Which of the following escape sequence represents tab?


A) \t\r
B) \b
C) \a

D) \t

ANSWER:  D


Explanation: \t is used to represent tab which means a set of blank spaces in a line.

 

12. Who created C++?

A) Dennis Ritchie
B) Bjarne Stroustrup
C) Ken Thompson
D) Brian Kernighan

ANSWER:  B

 


Explanation: Bjarne Stroustrup is the original creator of C++ during 1979 at AT&T Bell Labs. advertisement

13. Which of the following is called insertion/put to operator?

A) >
B) >
C) <<
D) <

ANSWER:  C

 


Explanation: << operator is called insertion or put to operator i.e. insert/put things to console/files.

14. Which of the following is called extraction/get from operator?

A) <<
B) >>
C) >
D) <

ANSWER:  B


Explanation: >> operator is called extraction or get from operator i.e. extract/get things from console/files.

15. A language which has the capability to generate new data types are called ________________

A) Extensible
B) Overloaded
C) Encapsulated
D) Reprehensible

ANSWER:  A


Explanation: Languages that can produce/generate new data types are called extensible languages as they have the ability to handle new data types

 

16. Declaration a pointer more than once may cause ____

A.) Error

B) Abort

C.) Trap

D. ) Null

 

ANSWER:  C

 

17. Which one is not a correct variable type in C++?

A.) float

B.) real

C.) int

D.) double

 

ANSWER:  B

18. Which operation is used as Logical 'AND'

A.) Operator-&

B.) Operator-||

C.) Operator-&&

D.) Operator +

 

ANSWER:  C

 

19. An expression A.B in C++ means ____

A.) A is member of object B

B.) B is member of Object A

C.) Product of A and B

D.) None of these

 

ANSWER:  B

 

20. A C++ code line ends with ___

A.) A Semicolon (;)

B.) A Fullstop(.)

C.) A Comma (,)

D.) A Slash (/)

 

ANSWER:  A

 

21.  ______ function is used to allocate space for array in memory.

A.) malloc()

B.) realloc()

C.) alloc()

D.) calloc()

 

ANSWER:  D

 

22. A pointer pointing to a variable that is not initialized is called ____

A.) Void Pointer

B.) Null Pointer

C.) Empty Pointer

D.) Wild Pointer

 

ANSWER:  B

23. Default constructor has ____ arguments.

A.) No argument

B.) One Argument

C.) Two Argument

D.) None of these

 

ANSWER:  A

24. A class whos objects can not be created is known as _____

A.) Absurd Class

B.) Dead Class

C.) Super Class

D.) Abstract Class

 

ANSWER:  D

25. Which class allows only one object to be created.

A.) Nuclear Family Class

B.) Abstruct Class

C.) Singleton Class

D.) Numero Uno Class

 

ANSWER:  C

Explanation: 

Singleton class allows the programmer to declare only one object of it, If one tries to declare more than one object the program results into error.

26. Reusability of code in C++ is achieved through ____

A.) Polymorphism

B.) Inheritance

C.) Encapsulation

D.) Both A and B

 

ANSWER:  B

Explanation:

Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class.

 

27. In CPP, members of a class are ______ by default.

A.Public

B.) Private

C.) Protected

D.) Static

 

ANSWER:  B

Explanation:

Members of a class are private by default and members of struct are public by default.

 

28. In C++ Program, inline functions are expanded during ____

A.) Run Time

B.) Compile Time

C.) Debug Time

D.) Coding Time

ANSWER:  B

Explanation:

Inline function is a function that is expanded in line when it is called. When the inline function is called whole code of the inline function gets inserted or substituted at the point of inline function call. This substitution is performed by the C++ compiler at compile time

29. To perform file input / output operation in C++, we must include which header file?

A. <fiostream>

B.) <ifstream>

C.) <ofstream>

D.) <fstream>

ANSWER:  D

Explanation:

To do input and output, you will need to load the iostream header file. You may also need to load the fstream (file I/O) and/or iomanip (format manipulation) header files.

30. An exception in C++ can be generated using which keywords.

A.thrown

B.) threw

C.) throw

D.) Throws

ANSWER:  C

Explanation:

Exception handling in C++ consist of three keywords: try, throw and catch: The try statement allows you to define a block of code to be tested for errors while it is being executed. The throw keyword throws an exception when a problem is detected, which lets us create a custom error.




--------------------------------------------------------------

Thanks for checking out our Computer programming (C++) Questions and Answers! I hope the information was helpful. Please let us know in the comments section below if you have anything to add or think I missed something important. As always, feel free to share this post’s link on your social networks and never forget to appreciate and Like our Facebook other media Pages!



If you have any questions, then you should join our Telegram chat group. We will help you solve your problems with blogging and SEO.


Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.