C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Point Out Errors (Q.No. 4)
4.
Which of the following is correct about err used in the declaration given below?
 typedef enum error { warning, test, exception } err;
It is a typedef for enum error.
It is a variable of type enum error.
The statement is erroneous.
It is a structure.
Answer: Option
Explanation:

A typedef gives a new name to an existing data type.
So err is a new name for enum error.

Discussion:
12 comments Page 2 of 2.

Sharmi said:   8 years ago
Give explanation for this.

Nagu said:   8 years ago
Enum is keyword like structure keyword.

(example)
you creat structure this way
struct (structure name)
{
(structure member or element)
} ;
same way using enum
(example)
enum (enum name)
{
(enum member or element)
};

So enum is keyword and error is enum name.


Post your comments here:

Your comments will be displayed after verification.