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

Flow chart, flow chart for calculating the volume of sphere

flow chart for calculating the volume of sphere

Area under curve, write a program to find the area under curve y=f(x) betwe...

write a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits a and b

Create a programming system, Your task is to create a programming system fo...

Your task is to create a programming system for a ferry. The ferry transports passengers and vehicles (cars, busses, lorries and bicycles). The ferry has space for 200 passengers a

Operator overloading - c++ program, Operator overloading - c++ program: ...

Operator overloading - c++ program: Write a program in c to define operator overloading. class matrix{                   private :                 int x[2][2];

Stone game, how to write a c program for stone game

how to write a c program for stone game

Calculate and display the marks and grade for each student, In this assignm...

In this assignment you are required to develop a program that allows the creation, viewing and storage of information about ITECH7603 Students. In order to complete the task you ha

Algorithms, algorithm to find out all the factors of given positive integer...

algorithm to find out all the factors of given positive integers

Develop custom mql4 code, Develop Custom Mql4 Code/Fxdreema block Projec...

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

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