Computer Science, asked by Meganlau, 11 months ago

1. For the following code:
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;
}

Please tell me the output: ?

2. For the following code:
enum fruit_tag {
BLUEBERRY,
BANANA,
PINEAPPLE,
WATERMELON
};
typedef enum fruit_tag fruit_t;

void printFruit(fruit_t myFruit) {
switch(myFruit) {
case BLUEBERRY:
printf("a blueberry");
break;
case BANANA:
printf("a banana");
break;
case PINEAPPLE:
printf("a pineapple");
break;
case WATERMELON:
printf("a watermelon");
break;
}
}

void compareFruit(fruit_t fruit1, fruit_t fruit2) {
if (fruit1 > fruit2) {
printFruit(fruit1);
printf(" is larger than ");
printFruit(fruit2);
}
else {
printFruit(fruit1);
printf(" is smaller than ");
printFruit(fruit2);
}
}

int main(void) {
fruit_t myFruit = PINEAPPLE;
fruit_t otherFruit = BLUEBERRY;
compareFruit(myFruit, otherFruit);
return 0;
}

Please tell me the output?:

3.What is the output of the following code?,

1 double d = 4.669;
2 printf("My number is %.2f.",d);

4. What is the value of the character '!' in binary?

Answers

Answered by anurag7771
5
I am not happy to answer wthis was
Answered by posabalachandra798
46

Answer:

1. This Fruit is 8.60 grams.

2. a pineapple is larger than a blueberry.

3. 4.67.

4. 100001.

Similar questions