69.1k views
1 vote
Consider the following statements:

struct rectangleData
{
double length;
double width;
double area;
double perimeter;
};

rectangle bigRect;

Which of the following statements is valid in C++?

a. perimeter = 2 * (length + width);
b. cin >> bigRect.length;
c. cin >> bigRect;
d. area = length * width;

1 Answer

0 votes

Final answer:

The correct answer is Statement b, which uses the dot operator to access the 'length' member of the 'bigRect' structure and reads a value into it from the standard input stream using 'cin'.

Step-by-step explanation:

The question asks which statement is valid in C++ given a rectangle structure definition. The statements are related to accessing and manipulating data within a structure in C++.

Statement a is incorrect because it does not reference the structure before its member variables.

Statement b is valid and properly uses the dot operator to access a member of the structure and read a value into it from the standard input stream using cin.

Statement c is invalid because cin cannot read an entire structure without an overloaded operator.

Statement d is incorrect for the same reason as statement a; it does not reference the structure prior to accessing its members.

User Krishnamurthy
by
7.9k points