What would be the value of x and y? [code]TYPE color IS (red, green, blue, yellow, purple, orange, black) VARIABLE x : INTEGER; VARIABLE

Quốc Ân

New member
What would be the value of x and y?
Code:
TYPE color IS (red, green, blue, yellow, purple, orange, black)
VARIABLE x : INTEGER;
VARIABLE y : color;
x <= color'POS(green);
y <= color'LEFTOF(green);
A. red, green
B. green, red
C. red, 2
D. 2, red
 
Answer: d
Explanation: Since x is an integer type and is assigned the value returned by ‘POS attribute. The value returned will be the position of green value which is 2. Another variable y can take any value within type color. The value in the left of green is red.
 

Tìm kiếm

Back
Top