Explain enumerated constants, C/C++ Programming

Assignment Help:

Enumerated Constants

Enumerated constants enable the creation of new types and then explain variables of these types so that their values are restricted to a set of possible values.

e.g.

 enum Colour{RED, BLUE, GREEN, WHITE, BLACK};

Colour is the name of an enumerated data type. It makes RED a symbolic constant with the value 0, BLUE a symbolic constant with the value 1 and so on.

- Each enumerated constant has an integer value. If the program doesn't specify or else, the first constant will have the value 0, the remaining constants will count up by 1 as compared to their predecessors.

- Any of the enumerated constant can be initialised to have a particular value, though; those that are not initialised will count upwards from the value of previous variables.

e.g.

enum Colour{RED = 100, BLUE, GREEN = 500, WHITE, BLACK = 1000};

The values assigned will be RED = 100,BLUE = 101,GREEEN = 500,WHITE = 501,BLACK = 1000

 

  • You can explain variables of type Colour, but they can hold only one of the enumerated values. In our case RED,BLUE,GREEEN,WHITE,BLACK .
  • You can declare objects of enum types.

 


Related Discussions:- Explain enumerated constants

Wap in c to find determinant of matrix order 3x3 , Normal 0 fal...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Implementation of the dictionary class, Implementation of the Dictionary cl...

Implementation of the Dictionary class: int Dictionary::find_word(char *s) {    char word[81];    for (int i = 0; i       if (stricmp(words[i].get_word(word),s) =

Padovan string , .write a program that counts the number of occurrences of ...

.write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program in java // aakash , suraj , prem sasi kumar kamaraj college

Help me for an programming contest .., Pebble Merchant Problem Description...

Pebble Merchant Problem Description There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides

Data structyres, What data structure would you mostly likely see in a nonre...

What data structure would you mostly likely see in a nonrecursive implementation of a recursive algorithm?Minimum 100 words accepted#

Loop, Write a program that writes your name on the monitor ten times. Write...

Write a program that writes your name on the monitor ten times. Write this program three times, once with each looping method.

Develop pidgin for windows, Develop Pidgin for Windows Project Descripti...

Develop Pidgin for Windows Project Description: I want to build Pidgin (open source instant messenger) for Windows with D-Bus support enabled. I've effectively built both

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd