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

1. (15 pts) Circle T for true and F for false: T F a) Value Returning Functions

ID: 3807120 • Letter: 1

Question

1. (15 pts) Circle T for true and F for false: T F a) Value Returning Functions cannot use reference parameters. T F b) Arguments corresponding to value parameters can be variables. T F C ptrvar var, assigns the memory address of var to ptrvar T F d) The memory address of the first element of an array is called the Base Address. T F e) The elements of a C++ array must be homogeneous T F f Given the declaration int betal20; the statement cout beta; can be used to display all 20 elements of the array named beta on the standard output device T F g) If a program has the declarations enum Weather Type (SUNNY CLOUDY FOGGY, WINDY, int frequencyl4; then the statement cout K frequencyICLOUDY, is syntactically valid. T F h) The C++ statement typedef int Boolean, creates a new name of Boolean for the existing DataType int. T F A hierarchical structure has at least one component that is itself a structure. T F eneous T F k) The names of members in a structure must be unique for that structure T F e expression name first is used to access the first member of the structure variable name. T F rm) C++ checks for out-of-bounds array indexes at compile time T F n) Using an array index that is out of bounds results in a compile error. T F o) The reserved word const before an array parameter allows a function to change values of the array

Explanation / Answer

a) True

Even if the actual reference argument has a value and therefore its corresponding formal parameter also has a value when the function is called, the function can change the value of the formal parameter. As a result the value of the actual argument is also changed. This formal parameter behaves both as an input and output (or inout) argument.

b) True

In call by value, one can thus think of arguments as values

c) False

& is the address operator which is used to refer the address. * is the symbol which will store the actual value in the memory

d) True

The first address in the array is called as the base address i.e., the starting adress of the array. In case if we want to refer to the address of the array it will be enough to use just the base address that is the first address of the array to access the array elements

e) True

Irrespective of the programming language array can store the values of the same data type so it contains the elements of the same kind

f) False

cout<<beta will point only to the starting address or the first element of the beta[20]. So, only first element can be displayed.

If in case the cout<<beta[i] is included in the for or while loop then all the 20 elements can be dispalyed

g) True

h) True

Typedef Statement synta: typedef existingTypeName newTypeName

The typedef statement causes the compiler just to substitute the word int for every occurrence of the word Boolean in the every occurrence of the program. The typedef statement provides us with a very limited way of defining our own data types. Typedef does not create a new data type but it creates an additional name for an existing data type.

i) True

Since all the languages has a structure dedicated to itself and need to follow that structure by default all the programs is a structure by itself

j) False

The members of C++ need not be always of the same data type it can be of different data type as well so its always not homogeneous

k) True

It member names should be unique in the structure if its the same the compiler will be confused which member to access when so it should be unique

l) True

"name" is the structure name and the "first" is the name of the member. This can be accessed as name.first

m) False

Memory location outside the array is accessed. C++ wont check for the array index out of bounds during compile time or the run time.

n) True

Each access to an array index is checked against the current size of the array. So, it results in a compile error

o) False

const refers to constant. It wont allow to change the value.