Machine-translated by Google. Questions are authored in English.
Top

Discussion

#include <stdio.h>

typedef enum{
    Male, Female=0
}SEX;

int main()
{
  SEX var = Male;
  SEX var1 = Female;
  printf("%d %d",var, var1);
  return 0;
}

 

  • A.0 0
  • B.-1 0
  • C.Some Garbage Value 0
  • D.Compilation Error

Answer: A

Correct answer: 0 0

Male takes the default first value, 0, and Female is explicitly set to 0 as well. Duplicate values are legal - the restriction is on duplicate names, not on duplicate values - so both print 0.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.