Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What is a variable? A) A name and a type B) A name and a value C) A name, a t

ID: 3903763 • Letter: 1

Question

1. What is a variable?

A) A name and a type

B) A name and a value

C) A name, a type, and a value

D) A name, a type, and a memory location

2. All objects have what in common?

A) They have a name

B) They have a determinate value

C) They have a size

D) They can be assigned to

3. Which of the following is mandatory for a function definition?

A) A function body

B) A return value

C) A parameter

D) An enclosing class

4. Which expression performs a function call?

A) *f

B) &f

C) f[0]

D) f()

5. What is the meaning of the return value of the main function?

A) Non-zero indicates program success, zero indicates program failure.

B) Zero indicates program success, non-zero indicates program failure.

6. A function with a return type of void signifies

A) The function does not return

B) The function has no side-effects

C) The function has no return value

D) The function requires no arguments

7. A sequence of operators and their operands, followed by a semicolon is a(n):

A) Selection statement

B) Declaration statement

C) Compound statement

D) Expression statement

8. All assignment and compound assignment expressions return:

A) The left operand

B) The right operand

C) A temporary value

D) Nothing

9. All non-assignment, arithmetic operators, when used on values of type int or double, return:

A) The left operand

B) The right operand

C) A temporary value

D) Nothing

10. The return type of a comparison operator is:

A) bool

B) char

C) int

D) double

11. A unary operator requires how many operands?

A) 0

B) 1

C) 2

D) 3

12. What variable scope has the longest lifetime?

A) Block scope

B) Global scope

C) Class scope

D) Function scope

13. A variable whose initial value cannot be replaced must be declared as:

A) volatile

B) static

C) const

D) auto

14. When a value undergoes conversion, what happens?

A) The value gets moved

B) The value changes

C) A new value with the same type gets created

D) A new value with a different type gets created

15. C-style cast expressions and functional cast expressions are examples of:

A) Explicit conversions

B) Implicit conversions

C) Standard conversions

D) User-defined conversions

16. Which of the following describes a conversion where no information can be lost?

A) double to int

B) int to char

C) bool to int

D) int to double

17. Variables declared directly within a class are called:

A) Properties

B) Data members

C) Member variables

D) Attributes

18. Functions declared directly within a class are called:

A) Member functions

B) Subprocedures

C) Methods

D) Operations

19. A private member of a class can be accessed from:

A) Any function

B) Any function inside the same class

C) Any private function

D) Any private function inside the same class

20. A public member of a class can be accessed from:

A) Any function

B) Any function inside the same class

C) Any public function

D) Any public function inside the same class

21. The kinds of statements that repeatedly execute code are generally known as:

A) Cycles

B) Loops

C) Repetitions

D) Recurrences

22. Which of the following is always true about referrences?

A) A reference must be declared with an initializer

B) A reference does not store anything

C) A reference stores an address

D) A reference can refer to multiple variables over it's lifetime

23. A pointer with the value 0 is known as:

A) A dangling pointer

B) An empty pointer

C) A void pointer

D) A null pointer

24. A condition is convertible to:

A) void*

B) int

C) bool

D) string

25. Another term for a compound statement is:

A) An aggregate

B) A fragment

C) A sequence

D) A block

Explanation / Answer

1) Variable has a name,type and memory location.Consider int x it has type int , name "x" and is consuming memory

3) For function definition, function body is required.As a function can be void fun() in which no return type or parameter is required and it need not be enclosed in a class if we don't want to call it

5) answer is B). returning 0 always indicates that program has been terminated after successful execution

6) void indicates that function has no return value that is it do not return anything

8) Both assignment and compound assignment store the result of expression in left operand.

10) comparison operator returns true or false depending on the type of expression that is returns bool values

11) Unary operator requires 1 operand like a++. Unary means 1

13) const is used if we do not want any variable to be changed

16) No info is lost during conversion of bool to int as int can be converted to bool because a non 0 value represents true 0 represents false

17) These variables are member of that class only hence termed as member variable

18) same as above. member function

19) B

21) loops are used for repeated execution of a part of code

23) D. Null pointer actually points to 0th block in memory

24) condition always yields result as true or false that is a bool value

I have answered all the questions about which i am confident

Leave doubts in comment section if any.