Purchase Solution

A C program that uses enumerated types

Not what you're looking for?

Ask Custom Question

Create a set/list of enumerated constants called week that contains the days of the week. Have a variable called today that is of type week. Assign a value to today. If the day is Monday through Friday, print "Go to work!" If the day is Saturday or Sunday, print "You can rest today!"

Purchase this Solution

Solution Summary

In this solution I provide a simple and easy to understand C program that uses an enumerated type to represent the days of the week. The program reads input from the user and prints a different message depending on which day of the week was entered.

Solution Preview

The point of using an enumeration type is that you can provide symbolic names for values that are related. The example of days of the week is a good one. We define an enum using the following statement:

enum week {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};

This provides us with an enum that is available for us to use for other variable declarations. So we can create a variable "today" like this:

enum week today;

Now it is possible to assign the value "Monday" to this variable:

today = Monday;

Notice that we're not using " around the name Monday. That's ...

Purchase this Solution


Free BrainMass Quizzes
Classical Mechanics

This quiz is designed to test and improve your knowledge on Classical Mechanics.

Variables in Science Experiments

How well do you understand variables? Test your knowledge of independent (manipulated), dependent (responding), and controlled variables with this 10 question quiz.

Intro to the Physics Waves

Some short-answer questions involving the basic vocabulary of string, sound, and water waves.

Introduction to Nanotechnology/Nanomaterials

This quiz is for any area of science. Test yourself to see what knowledge of nanotechnology you have. This content will also make you familiar with basic concepts of nanotechnology.

Basic Physics

This quiz will test your knowledge about basic Physics.