Given the following snippet of code, answer the following two questions based on the code: typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days; days x = Mon, y = Sat; while (x != y) { x++; } y++; printf("x = %d, y = %d", x, y); 1. What value will be printed for variable x? [ Select ] . 2. What value will be printed for variable y? [ Select ]

Respuesta :

Answer:

1) The value of x will be 6.

2) The value of y will be 7.

Explanation:

1) The value of x will be 6.  

The enum values are labeled by default from 1. This means that Sun = 1, Mon = 2, Tue = 3 and so on.  

So, x = Mon = 2 and y = Sat = 6  

x increases up to y = 6 in the while loop.  

and then y also increments by 1.  

2)So the value of y = 7.  

You will need actual printf("Sun") or printf("Mon") for printing the actual text for the enum.

ACCESS MORE