Question

In: Computer Science

Relational Operators For Cpp Discuss why relational operators can be used with enumeration types. Provide at...

Relational Operators

For Cpp

Discuss why relational operators can be used with enumeration types. Provide at least 2 examples of relational expressions with enumeration types. Explain your examples

Solutions

Expert Solution

The syntax for enumeration is:
enum typeName {value1, value2,…}, in which value1, value2, . . . are identifiers called enumerators. In C11, enum is a reserved word. By listing all of the values between the braces, you also specify an ordering between the values. That is, value1 < value2 < value3 <.... Thus, the enumeration type is an ordered set of values. Moreover, the default value assigned to these enumerators starts at 0. That is, the default value assigned to value1 is 0, the default value assigned to value2 is 1, and so on. (You can assign different values—other than the default values—for the enumerators when you define the enumeration type.) Also notice that the enumerators value1, value2, . . . are not variables.
The statement:
enum colors {BROWN, BLUE, RED, GREEN, YELLOW};
defines a new data type called colors, and the values belonging to this data type are BROWN, BLUE, RED, GREEN, and YELLOW.


Related Solutions

Your textbook mentions that relational operators can be used to compare letters and words, thanks to...
Your textbook mentions that relational operators can be used to compare letters and words, thanks to ASCII. This simple program will ask the user to enter two letters and then two words to see if we can really "sort" these entries alphabetically with relational operators. Prompts: This is a Letter and Word sorting program Enter two different letters separated by a space: [assume user inputs: b a] Enter two different words separated by a space: [assume user inputs: bob alex]...
how can object -relational database be used to implement an SDBMS?
how can object -relational database be used to implement an SDBMS?
How/why can each type of database (relational, object-oriented, and multidimensional) be utilized in healthcare? Provide examples...
How/why can each type of database (relational, object-oriented, and multidimensional) be utilized in healthcare? Provide examples as support.
What types of information can variance analysis provide to the manager? How can it be used?...
What types of information can variance analysis provide to the manager? How can it be used? Give examples.
Discuss various types of pumping that can be used in lasers.            [10]
Discuss various types of pumping that can be used in lasers.            [10]
explain different types of switches and scanning and provide examples of when they can be used...
explain different types of switches and scanning and provide examples of when they can be used My major is rehabilitation services. the class is assistuve technology. the book is assistive technology for people with disabilities
Discuss the various types of business-type funds used in governmental units and provide an example of...
Discuss the various types of business-type funds used in governmental units and provide an example of when each is appropriate. Include how monitoring and reporting of business-type funds is similar and how it differs from the same functions in a corporation.
Discuss the various types of business-type funds used in governmental units and provide an example of...
Discuss the various types of business-type funds used in governmental units and provide an example of when each is appropriate. Include how monitoring and reporting of business-type funds is similar and how it differs from the same functions in a corporation.
Different types of software can be used for data managment. Excel and SPSS and discuss specific...
Different types of software can be used for data managment. Excel and SPSS and discuss specific SPSS software features that make it preferable to Excel for data managment. provide examples illustrating when electing to use the SPSS could be preferable to Excel and vice versa
Different types of software can be used for data management. Compare Excel and SPSS and discuss...
Different types of software can be used for data management. Compare Excel and SPSS and discuss specific SPSS software features that make it preferable to Excel for data management. Provide examples illustrating when electing to use SPSS could be preferable to Excel and vice versa.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT