Question

What will be the output of the following code int x = 5; int y =...

What will be the output of the following code

int x = 5;

int y = 2;

f(x,y);

printf(“%s \n”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y\n ”);

f(int x, int y) {

x = 2*y;

printf(“%s \n”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y \n”);

}

a. x is less than or equal to 2*y x is less than or equal to 2*y

b. x is less than or equal to 2*y x is more than two times larger than y

c. x is more than two times larger than y x is less than or equal to 2*y

d.x is more than two times larger than y x is more than two times larger than y

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer is Option b. x is less than or equal to 2*y x is more than two times larger than y.

Explanation:

f(x,y); this calls the function f(int x, int y);

x=2*y;

x= 2*2 which is 4

so, x/y>2 which is 4/2>2 and it is false. 2 is not greater than 2.

So, x is less than or equal to 2*y x is more than two times larger than y.

Add a comment
Know the answer?
Add Answer to:
What will be the output of the following code int x = 5; int y =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT