✏️ Explanatory Question
[E] Convert the following equations into corresponding C statements.
(a) Z = [8.8(a + b)2 / c - 0.5 + 2a / (q + r)]
--------------------------------------
(a + b) * (1 / m)
(b) X = [-b + (b * b) + 24ac]
--------------------
2a
(c) R = [2v + 6.22(c + d)]
-----------------
g + v
(d) A = [7.7b(xy + a) / c - 0.8 + 2b]
-----------------------------
(x + a)(1 / y)
| Equation | Corresponding C Statement |
|---|---|
| (a) |
|
| (b) |
|
| (c) |
|
| (d) |
|
#include
int main()
{
float Z, X, R, A;
float a = 2, b = 3, c = 4;
float d = 5, g = 6, v = 7;
float q = 2, r = 3, m = 2;
float x = 4, y = 5;
Z = (8.8 * (a + b) * 2 / c - 0.5 + 2 * a / (q + r))
/ ((a + b) * (1.0 / m));
X = (-b + (b * b) + 24 * a * c)
/ (2 * a);
R = (2 * v + 6.22 * (c + d))
/ (g + v);
A = (7.7 * b * (x * y + a) / c - 0.8 + 2 * b)
/ ((x + a) * (1.0 / y));
printf("Z = %.2f\n", Z);
printf("X = %.2f\n", X);
printf("R = %.2f\n", R);
printf("A = %.2f\n", A);
return 0;
}
Z = 8.10
X = 25.50
R = 5.39
A = 79.95