Answer the following statements true (T) or false (F)

1. A for-loop is a convenient way to step through an array.
2. A C++ structure, or struct, like the C++ array, is a homogeneous data structure. (i.e.,
all data is of the same type)
3. Structure definitions are usually global (defined outside any functions).
4. A structure member is access using the index operator [ ], with the member name as
index. [ ]
5. A structure variable can be defined directly in the same statement that defines a structure definition.


1. True
The for-loop provides convenient places for definition and initialization,
testing, and updating a loop control variable. This variable is convenient to use as an
array index in stepping through the array, as:
```
for(int i = 0; i < declared_size; i++)
cout << array[i} << " ";
cout << endl;
```
2.False
The struct provides a mechanism to define a collection of values that may
be of several different types.
3.True
A structure definition is a type that, like const definitions, we usually
want to be available everywhere in a program that follows the structure definition.
4. False
Access to structure members is made by giving the structure tag,
followed by a dot followed by the member name.
Example: Given the structure definition and variable definition such as
```
struct CDAccount
{
double balance,
double interestRate;
int term;
};
CDAccount account1;
```
Access to member variables of account1 may be had using the dot operator:
account1.balance1
account1.interestRate
5. True
The variables s and t are structure variables of structure type myStruct under the following definitions:
```
struct myStruct
{
int i;
double d;
} s, t;
```

Computer Science & Information Technology

You might also like to view...

The use of compensating controls involves a three-way process.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the hexadecimal values below would be considered Web-safe?

A) #66ccbb B) #229966 C) #0033ff D) #990033dd

Computer Science & Information Technology

Which example best represents a queue?

A. print jobs sent to a printer B. a pickup game of football C. items selected via a random number generator D. people exiting a sporting event

Computer Science & Information Technology

Explain how SCADA uses remote terminal units (RTUs).

What will be an ideal response?

Computer Science & Information Technology