JavaScript is required

Kết quả của chương trình sau là gì #include void hoanvi(int * px, int * py) { int z; z = * px; * px = * py; * py = z; }; void main() { int a = 15, b = 21; hoanvi(a, b); printf(“ % d % d”, a, b); };

A.

“15 21”

B.

“21 15”

C.

Báo lỗi khi thực hiện chương trình

D.

Kết quả khác

Trả lời:

Đáp án đúng: B


The code has an error because the `hoanvi` function expects pointers as arguments (int *), but the function call `hoanvi(a, b)` passes the values of `a` and `b` (int) instead. This leads to a type mismatch, resulting in a compilation error. The correct way to call the function is to pass the addresses of `a` and `b` using the `&` operator: `hoanvi(&a, &b)`.

Câu hỏi liên quan