CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What are enumerations?

Answer: enumerations is one type of user defined data type



Category C Interview Questions & Answers - Exam Mode / Learning Mode
Rating (3.5) By 52 users
Added on 3/13/2013
Views 761
Rate it!
Question: What are enumerations?
Answer:

enumerations is one type of user defined data type Source: CoolInterview.com

Answered by: sekhar | Date: 7/30/2008 | Contact sekhar Contact sekhar

Enums are group of symbolic constant each having some integer value.

enum(PASS_MARK=60,MERIT_MARK=70)

defines two symbolic constant PASS_MARK and MERIT_MARK as 60 and 70,- it could be done with #define as well.

However without specific values ,- the values are assigned automatically ,- starting with 0 for the first element and 1 for the second, 3 for the second etc.

In case if we state a number for the first element then it will increment the value of each consecutive elemts with '1'.

enum(MON=1,TUE,WED,THU,FRI,SAT,SUN);

gives the values of 1-7 to the names of days. Source: CoolInterview.com

Answered by: Andrew Gecse | Date: 2/10/2009 | Contact Andrew Gecse Contact Andrew Gecse

enumerations can be used in place of a macros for example let us consider an example where a function is failing for many reasons like array out of bounds, divide by zero ,and memory allocation failure
when you call such a function and if something goes wrong you may not know for what reason exactly in that case you can make an enum like
enum error
{
ARRAY_OUT =0,
MEMORY_FAIL,
DIVIDE_ZERO
}
and so on instead of defining each one by macro
Then based on return value it would be easy to locate eror . And ofcourse it is a user defined type.The values assigned will be from 0 to the number of elements present . you can also assign different values in between like
enum week {
sunday, monday, tuesday=4,wednesday,thursaday}
then wednesday and thursday would have a value of 5 and 6

Source: CoolInterview.com

Answered by: shwetavg | Date: 6/3/2009 | Contact shwetavg Contact shwetavg

Enums are group of symbolic constant each having some integer value.

enum(PASS_MARK=60,MERIT_MARK=70)

defines two symbolic constant PASS_MARK and MERIT_MARK as 60 and 70,- it could be done with #define as well.

However without specific values ,- the values are assigned automatically ,- starting with 0 for the first element and 1 for the second, 3 for the second etc.

In case if we state a number for the first element then it will increment the value of each consecutive elemts with '1'.

enum(MON=1,TUE,WED,THU,FRI,SAT,SUN);

gives the values of 1-7 to the names of days. Source: CoolInterview.com

Answered by: ranjith | Date: 8/25/2010 | Contact ranjith Contact ranjith


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
Write down the equivalent pointer expression for reffering the same element a[i][j][k][l]?
View Answer
What is the use of typedef?
View Answer
Which mistakes are called as token error?
View Answer
What is the function of % using in formatted string.
View Answer
How to print the names of employees or students in alphabetical order using C programming?
View Answer
How should i rate on the basis of the basis of the scenario the insertion sort , bubble sort , Quick Sort?
View Answer
Can we print values from 1 to 100 without using for,while,do-while,if etc.?answer should be logical.
View Answer
How to write a program to print its own source code?
View Answer
What are the advantages of pointers,give me programs containing variables and pointer variables?
View Answer
I want source code of series of prime numbers.
View Answer
There is any methodology in which we can print a string in c without using semicolon(;)
suggest me if there is ?
View Answer
What is the difference between the following statements?
int a[4]={1,2,3,4};
int a[]={1,2,3,4);
View Answer
How can we get direct printout of a c file without giving print command from bin or tc?eg i want to get the printout of a program directly after execution from the c window itself.
View Answer
Write a C program that will convert Simple Sentence to Complex/Compound Sentence.
View Answer
Can anyone share his code which would accept a sentence, then count the number occurrence of the words excluding spaces.All is done using linked list.
View Answer
using c-strings write a program that will analyse the text"1.1my brother is taller than me.1.2 I am a boy of sixteen years old". The program should remove multiple spaces betweem words,find the longest word in the text,search and identify the number of letters"e", extact the number of integers , extract the number of doubles, extract the number of words in each sentence and identify the number of sentences in the text.
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All C Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
"Holiday Packages" announced as an advertisement are an example of _________: (a) Offer (b) Counter Offer (c) Invitation to Offer (d) None of the above
A match fixing contract between a player and a broker is a: (a) Valid Contract (b) Unenforceable Contract (c) Void Contract (d) Illegal Contract
When a bookseller sells a book on cash payment then it is called as ___________: (a) Unilateral Contract (b) Bilateral Contract (c) Executed Contract (d) Executory Contract
____________ agreements are created by situation: (a) Written (b) Oral (c) Void (d) Implied
Cache = 0.03125 Seconds