Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
760 views
in Computer by (69.8k points)
How does an enum statement differ from a typedef statement?

1 Answer

+1 vote
by (69.2k points)
selected by
 
Best answer

Typedef statement allows user to define an identifier that would represent an exiting data type. The user-defined data type identifier can be used further to declare variables. It has the following syntax 

typedef datatype identifier;

where datatype refers to exiting data type and identifier is the new name given to this datatype. For example 

typedef int nos;

nos here symbolizes int type and now it can be used later to declare variables like

nos num1,num2,num3; 

enum statement is used to declare variables that can have one of the values enclosed within braces known as enumeration constant. After declaring this, we can declare variables to be of this ‘new’ type. It has the following syntax 

enum identifier {value1, value2, value3……,valuen);

where value1, value2 etc are values of the identifier. For example

enum day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday} 

 We can define later

enum day working_day;

working_day=Monday;

The compiler automatically assigns integer digits beginning with 0 to all enumeration constants. 

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...