What will be the output of the following code int x = 5; int y = 2; f(x,y); prin
ID: 3821880 • Letter: W
Question
What will be the output of the following code
int x = 5;
int y = 2;
f(x,y);
printf(“%s ”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y ”);
f(int x, int y) {
x = 2*y;
printf(“%s ”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y ”);
}
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
Explanation / Answer
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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.