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

C++ PROGRAMMING Question 1 A one-dimensional array is a list of related values w

ID: 3594473 • Letter: C

Question

C++ PROGRAMMING

Question 1

A one-dimensional array is a list of related values with the same ____ that is stored using a single group name.

size

data type

value

offset

Question 2

Consider the declarations const int ARRAYSIZE = 7; and double length[ARRAYSIZE] = {7.8, 6.4, 4.9, 11.2};. How many elements will be initialized to zero?

none

one

two

three

Question 3

The statement cin >> grade[4] >> prices[6]; causes ____ values to be read and stored.

2

4

6

10

Question 4

Passing addresses is referred to as a function pass by reference because the called function can reference, or access, the variable whose address has been passed.

True

False

Question 5

A called function can return more than one legitimate value to its calling function.

True

False

· Question 6

The new and delete operators provide a mechanism for enlarging and shrinking arrays.

Answers:

True

False

· Question 7

Under a dynamic allocation scheme, the amount of storage to be allocated is determined and adjusted ____.

Answers:

at compile time

at runtime

when a program error occurs

interactively by the user

· Question 8

For dynamic allocation of memory to create new variables as a program is running, pointers are ____.

Answers:

required

helpful

not allowed

allowed

· Question 9

Adding 1 to a pointer causes the pointer to point to the ____.

Answers:

next element of the type pointed to

first element of the type pointed to

next byte

next block

· Question 10

The expression *gPtr + 3 is equivalent to *(gPtr + 3).

Answers:

True

False

· Question 11

Any subscript used by a programmer is automatically converted to a(n) ____ by the compiler.

Answers:

integer

expression

offset

equivalent pointer expression

· QUESTION 12

What is the output of the following C++ code?

     int *p = new int;

     int *q = new int;

     p = q;

     *q = 75;

     delete p;

     p = new int;

     *p = 26;

     q = new int;

     q = p;

     *q = 62;

     cout << *p << " " << *q << endl;

Selected Answer:

62 62

· Question 13

A class ____ automatically executes whenever a class object goes out of scope.

Selected Answer:

destructor

Answers:

constructor

destructor

pointer

exception

· Question 14

C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array.

Selected Answer:

True

Answers:

True

False

· Question 15

1 out of 1 points

If a is a class object and p, a pointer, is a public member of the class, what will the following statement do?

          cout << *a.p;

Answers:

Output the dereferenced value pointed to by p

Result in a compiler error

Output the address stored in p

Output the value stored in a

· Question 16

Which of the following is true about classes and structs?

Selected Answer:

You cannot use the member access specifier private in a struct.

Answers:

By default, all members of a struct are public and all members of a class are private.

A struct variable is passed by value only, and a class variable is passed by reference only.

An assignment operator is allowed on class variables, but not on struct variables.

You cannot use the member access specifier private in a struct.

· Question 17

What will the following code display?

int numbers[] = { 99, 87, 66, 55, 101 };

   for (int i = 1; i < 4; i++)

    cout << numbers[i] << " ";

Answers:

99 87 66 55 101

87 66 55 101

87 66 55

Nothing. This code has an error.

· Question 18

Given the declaration Student *student;, the statement student = new Student[50]; dynamically allocates a dynamic array of the type ____.

Answers:

Student

student

pointer

Student*

· Question 19

Which is Abstract Data Type in C++

Answers:

Class

int

float

array

· Question 20

By default functions available in C++ language are

Answers:

Constructor

Copy Constructor

Destructor

Assignment Operator

All of above

· Question 21

What is the output of this program?

Answers:

10,20,30,40,20,

10,20,30,40,40,

Compiler Error

Runtime Error

· Question 22

A linked list is a random access data structure such as an array.

Answers:

True

False

· Question 23

Because initially the list is empty, the pointer listData must be initialized to ____.

Answers:

NULL

EMPTY

NIL

NOP

· Question 24

In a linked list, we always want listData to point to the ____ node.

Answers:

key

main

first

last

· Question 25

To access the fifth element in a list, we must first traverse the first four elements.

Answers:

True

False

· Question 26

To delete a given item from an ordered linked list, there is no need to search the list to see whether the item to be deleted is in the list.

Answers:

True

False

size

data type

value

offset

Explanation / Answer

Ans 1- A one-dimensional array is a list of related values with the same "Data Type" that is stored using a single group name.

Array:-An array is a collection of elements of the same data type. An array is used to store variable of same data type.

Ans 2- "Three" elements will be initialized to zero,Because only 4 elements are initialized in the array {7.8, 6.4, 4.9, 11.2}, Rest three elements wiil be initialized to zero because size of the array is given as 7.

Ans 3- The statement cin >> grade[4] >> prices[6]; causes "2" values to be read and stored.

Ans 4- True, Because explicitly passing addresses to a function using the address operator effectively is called as pass by reference.

Thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote