1. Suppose that the function f () has the following definitions: int f (int a, i
ID: 3558895 • Letter: 1
Question
1. Suppose that the function f () has the following definitions:
int f (int a, int b, int c) {
.....
}
which of the following statements are illegal? Suppose i has type of int and x has type of double.
a) i = f (10, 20, 30)
b) x = (10, 20, 30)
c) i = f (5.25, 3.45, 7.22)
d) x = f (5.25, 3.45, 7.22)
e) f (10, 20, 30)
f) f (10, 20)
2. Write a single C statement to accomplish each of the following tasks:
a) Assign the product of x and y to p and increment the value of y by 3 after the calculation.
b) Decrement variable X by 3, then subtract it from variable result.
c) Add variable X to variable sum, then increment X by 5.
3. The mathematical operation:
min (x, y)
can be represented by the conditional expression:
(x < y) ? x : y
In a similiar fashion, using only conditional expression, describe the mathematical operation:
min (x, y, z)
Explanation / Answer
1. Suppose that the function f () has the following definitions:
int f (int a, int b, int c) {
.....
}
which of the following statements are illegal? Suppose i has type of int and x has type of double.
a) i = f (10, 20, 30) // LEGAL
b) x = (10, 20, 30) // ILLEGAL
c) i = f (5.25, 3.45, 7.22) // ILLEGAL
d) x = f (5.25, 3.45, 7.22) // ILLEGAL
e) f (10, 20, 30) // LEGAL
f) f (10, 20) // ILLEGAL
2. Write a single C statement to accomplish each of the following tasks:
a) Assign the product of x and y to p and increment the value of y by 3 after the calculation.
p = x*y; y+=3;
b) Decrement variable X by 3, then subtract it from variable result.
result-=(x-=3);
c) Add variable X to variable sum, then increment X by 5.
sum+=x; x+=5;
3. The mathematical operation:
min (x, y)
can be represented by the conditional expression:
(x < y) ? x : y
In a similiar fashion, using only conditional expression, describe the mathematical operation:
min (x, y, z) (x<y && x<z)?x:(y<x && y<z)?y:z
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.