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

I need help with these question: 1.Which of the following incorrectly initialize

ID: 3856453 • Letter: I

Question

I need help with these question:

1.Which of the following incorrectly initializes the first member, name, defined as a character array in a structure?

a. emp.name = “Billy”;

b. name = “Billy”;

c. strcpy(emp.name, “Billy”);

d. both a and b

e. both b and c

2. In order to compare two structures, it is not necessary to compare the individual members.

a. TRUE

b. FALSE

3.Suppose a pointer to a structure, bookPtr, is defined. This structure also contains a member, price that is a pointer to a double. Provide the equivalent to *bookPtr->price?

4. Which of the following incorrectly initializes the enumerators of type Colors to the following values 0, 1, 2, 8, 9, 10, respectively?

a. enum Colors {RED, ORANGE, YELLOW, GREEN = 8, BLUE, PURPLE};

b. enum Colors {RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE};

c. enum Colors {RED, ORANGE = 1, YELLOW, GREEN = 8, BLUE, PURPLE};

d. none of the above

5. Which of the following is not true about enumerated data types?

a. enumerators can be used as array subscripts

b. mathematical operators can be used to change the value of enumerators

c. the values of enumerators can be displayed in cout statements

d. enumerators must be unique within the same scope

6. This datatype can be used to create files and write information to them but cannot be used to read information from them.

7. Define a statement that opens the file info.txt for both input and output?

8. This member function can be used to store binary data to a file.

9. This state bit is set when an attempted operation has failed.

a. ios::failbit

b. ios::badbit

c. ios::hardfail

d. ios::goodbit

1.

Explanation / Answer

Solution :

1)

Answer : option d. both a and b
here a and b both are incorrect as array in C can not be assigned directly.

2)
FALSE

In C we have to compare all member of structure to compare two structures.


3)
*bookPtr->price points to the memory where price points.
here bookPtr->price points to price pointer.
by adding * in front of bookPtr->price, it will point to double value where price points.

if *price = 122.5 for some structure variable a.
and bookPtr points to a.
Then *bookPtr->price returns double value 122.5


4)
Answer : option b
here option b initialzie Colors to 0,1,2,3,4,5