Enum name_tag { BLUEBERRY, BANANA, PINEAPPLE, WATERMELON }; typedef enum name_tag name_t; struct fruit_tag { name_t name; double size; }; typedef struct fruit_tag fruit_t; fruit_t getBigger(fruit_t f, double d) { f.Size += d; return f; } int main(void) { fruit_t myFruit; myFruit.Name = BANANA; myFruit.Size = 5.2; myFruit = getBigger(myFruit, 3.4); printf("This fruit is %.2f grams.\n", myFruit.Size); return 0; }

Respuesta :

Answer:

The output of the given code is "This fruit is 8.60 grams".

Explanation:

In the given code there are some mistype errors, which is reduced in the attachment file, please find the attachment and its description as follows:  

  • In the program, an enum keyword is used, that defines a "name_tag" datatype, which assigns other values, that are "BLUEBERRY, BANANA, PINEAPPLE, WATERMELON".
  • In the next step, the typedef keyword is used, which creates the reference of the name_tag, and in the next step, a structure is declared, which defines the name as name_t and double variable size.
  • By using typedef a method "getBigger" is declared that adds input value in reference f and returns its value.
  • Inside the main method, the structure reference variable "myFruit" is created that assigns size value and name values, and in this reference variable, we call the method and print its return value.
Ver imagen codiepienagoya
ACCESS MORE