C Enumeration (Enum)
- Which of the following is correct about emp used in the declaration given below ?
typedef enum employ {Engineer, Doctor, Manager} emp;
-
View Hint View Answer Discuss in Forum
A typedef gives a new name to an existing data type.
So emp is a new name for enum employ.Correct Option: A
A typedef gives a new name to an existing data type.
So emp is a new name for enum employ.
- Which of the following is the correct output for the program given below?
#include <studio.h>
int main()
{
enum result {pass, fail, waiting};
enum result result1, result2, result3;
stud1 = pass;
stud2 = waiting;
stud3 = fail;
printf("%d %d %d\n",result1, result2, result3);
return 0;
}
-
View Hint View Answer Discuss in Forum
Enum elements always take values like 0, 1, 2, etc.
Correct Option: C
Enum elements always take values like 0, 1, 2, etc.
So pass = 0, fail = 1 and waiting= 2