JavaScript is required

Kết quả in ra màn hình của chương trình sau là gì:

A.

Vòng lặp vô hạn

B.

“ 2”

C.

“ 1 2”

D.

Kết quả khác

Trả lời:

Đáp án đúng: A


The code initializes an integer variable `i` to 1. It then enters a `while` loop that continues as long as `i` is less than or equal to 2. Inside the loop, the current value of `i` is printed to the console, followed by a space. After printing, `i` is incremented by 1. Thus, the loop will execute twice, printing 1 and 2, separated by a space.

Câu hỏi liên quan