vault backup: 2024-10-12 20:47:02
This commit is contained in:
parent
94dd9d5d74
commit
84bf3689e5
@ -23,6 +23,18 @@ double triangle_area(double base, double height)
|
|||||||
> 2. Write a function `check(x, y, n)` that returns `1` if both `x` and `y` fall between zero and `n - 1` inclusive. The function should return 0 otherwise. Assume that `x`, `y`, and `n` are all of type int
|
> 2. Write a function `check(x, y, n)` that returns `1` if both `x` and `y` fall between zero and `n - 1` inclusive. The function should return 0 otherwise. Assume that `x`, `y`, and `n` are all of type int
|
||||||
```c
|
```c
|
||||||
int check(int x, int y, int n) {
|
int check(int x, int y, int n) {
|
||||||
if (x < 0)
|
int in_range = 1;
|
||||||
|
if (x < 0 || y < 0) {
|
||||||
|
in_range = 0;
|
||||||
|
}
|
||||||
|
if (x > n - 1 || y > n - 1) {
|
||||||
|
in_range = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return in_range;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> 7. Suppose that function `f` has the following definition:
|
||||||
|
> `int f(int a, int b) { ... }`
|
||||||
|
> Which of the following statements are legal? Assume that `i` has type `int` and `x` has type `double`).
|
||||||
|
Loading…
Reference in New Issue
Block a user