Default value of enumarated varaible is first value of enum

module tb;
enum {A, B, C, D} state;
initial begin
$display(“Default value of enum variable = %0d”, state);
$display(“Name = %s”, state);
end
endmodule

outputs : Default value of enum variable = 0
# Name = A

module tb;
enum {A=1, B, C, D} state;
initial begin
$display(“Default value of enum variable = %0d”, state);
$display(“Name = %s”, state.name());
end
endmodule

Outputs: Default value of enum variable = 0
# Name =

Hello , Dave why in second code the default value of enumarated varaible is not coming as first value of enum.

Uninitialized variables should never be assumed to have a ‘default’ value. The only reason that your first example looks correct is because the underlying data type is integer which typically defaults to a value of 0, but you should never assume that this will always be the case.