C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 1TF

Mark the following statements as true or false.

  1. All members of a struct must be of different types. (1)

  2. A struct is a definition, not a declaration. (1)

  3. A struct variable must be declared after the struct definition. (1)

  4. A struct member is accessed by using the operator :. (2)

  5. The only allowable operations on a struct are assignment and member selection. (2)

  6. Because a struct has a finite number of components, relational operations are allowed on a struct. (2)

  7. Some aggregate input/output operations are allowed on a struct variable. (2)

  8. A struct variable can be passed as a parameter either by value or by reference. (4)

  9. A function cannot return a value of the type struct. (4)

  10. An array can be a member of a struct. (6, 7)

  11. A member of a struct can be another struct. (8)

a)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

False

Explanation of Solution

Given Information: All members of a struct must be of different types.

Explanation:In the C++ programming language, the struct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components. These components can be of different types. It means that a struct has both same type and different type component/members.

Conclusion:All Component/members of a struct can be of same types and can be of different types.Hence, the given statement is false.

b)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

true

Explanation of Solution

Given Information: Astruct is a definition, not a declaration.

Explanation:In the C++ programming language, struct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components of both same and different types.To use the struct, an instance/pointer/variable is declared and memory is allocated for the instance/pointer/variable of thestruct when they declared.

Conclusion: Astruct is used to define a structure. Hence, the given statement is true.

c)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

False.

Explanation of Solution

Given Information: A structvariable must be declared after the struct definition.

Explanation:In the C++ programming language, struct is a reserved keyword. This keyword is used to define a structure. To use the struct, an instance/pointer/variable is declared and memory is allocated for the instance/pointer/variableof the struct when they declared.

Conclusion: An instance/pointer/variable of the structcan be declared when required.

Hence, the given statement is false.

d)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

false

Explanation of Solution

Given Information: A structmember is accessed by using the operator (:).

Explanation:In the C++ programming language, the dot (.) operator is used to access the member of a struct. This operator is also known as member access operator.

Conclusion: Toaccess the member of a struct a member access operator (.) is used.

Hence, the given statement is false.

e)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

true

Explanation of Solution

Given Information: The only allowable operations on a struct are assignment and member selection.

Explanation:In the C++ programming language, Theassignment and member access operations are the two built in operations for astruct. The arithmetic and relational operations are not allowed on struct.

Conclusion: The assignment and member selectionoperations are the only allowableoperations on a struct.

Hence, the given statement is true.

f)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

false

Explanation of Solution

Given information: As a struct has a finite number of components, therefore, relational operations are allowed on a struct.

Explanation:In the C++ programming language, Thestruct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components. These components can be of different types. It means that a struct has both same type and different type component/members.The assignment and member access operations are the two built in operations for a struct. The arithmetic and relational operations are not allowed on struct.

Conclusion: The relational operations are not allowed on a struct.

Hence, the given statement is false.

g)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

False

Explanation of Solution

Given Information: Some aggregate input/output operations are allowed on a struct variable.

Explanation:In the C++ programming language, Thestruct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components. These components can be of different types. It means that a struct has both same type and different type component/members. The assignment and member access operations are the two built in operations for a struct. The arithmetic and relational or other aggregate input/output operations are not allowed on struct.

Conclusion: The aggregate input/output operations are not allowed on a struct.

Hence, the given statement is false.

h)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

True

Explanation of Solution

Given Information: A struct variable can be passed as a parameter either by value or by reference.

Explanation:In the C++ programming language, struct is a reserved keywordused to define a structureof fixed number of components of same or different types. Astruct can be passed as a parameter to a functioneither by value or by reference.

Conclusion: A struct variable can be passed as a parameterto a function either by value or by reference.

Hence, the given statement is true.

i)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

False

Explanation of Solution

Given Information: A function cannot return a value of the type struct.

Explanation:In the C++ programming language, struct is a reserved keyword used to define a structure of fixed number of components of same or different types. A struct can be passed as a parameter to a function either by value or by reference. A function can also return a value of structtype.

Conclusion: A function can return a value of struct type.

Hence, the given statement is false.

j)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

True

Explanation of Solution

Given Information: An array can be a member of a struct.

Explanation:In the C++ programming language, the struct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components/members. These components can be of different types. The component/member can be of array type, struct type, integer type, float type, char type, string type, char type, or Boolean type.

Conclusion:An array can be a member of a struct.

Hence, the given statement is true.

k)

Expert Solution
Check Mark
Program Plan Intro

To find whether given statement is true or false.

Program Description Answer

true

Explanation of Solution

Given Information: A member of a struct can be another struct.

Explanation:In the C++ programming language, the struct is a reserved keyword. This keyword is used to define a structure. A structure is a collection of fixed number of components/members. These components can be of different types. The component/member can be of array type, struct type, integer type, float type, char type, string type, char type, or Boolean type.

Conclusion: A struct can be a component/member of another struct.

Hence, the given statement is true.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Car Class in C++ language  whole task is in the picture
The main difference between structures and classes is: Select one: a. There is no difference between structures and classes b. That classes always require new be used with them while structures do not c. How they access member variables d. Whether they default to public or private access
PROBLEM COPY CONSTRUCTOR Copy Constructor Ebox team created a course for their employees and wanted to provide the same course for the faculties in one of the colleges. So they decided to replicate the course using a copy constructor. Write a program to display the given details with the normal constructor and the copy constructor. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Course has the following public data members. Data Type string string string string Variable Name course_hame sessionname1 sessionname2 sessionname3 Define a CO the came order 2e e Type here to search
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY