void main() { int x = 0; switch(x) { case 1: printf( “One” ); case 0: printf( “Zero” ); case 2: printf( “Hello World” ); } } What is the result of the following code?

void main()

{

int x = 0;

switch(x)

{

case 1: printf( “One” );

case 0: printf( “Zero” );

case 2: printf( “Hello World” );

}

}

What is the result of the following code?

A. One

B. Zero

 

C. Hello World

D. ZeroHello World

Hướng dẫn

Chọn D là đáp án đúng

Xem lời giải

Xem lời giải

Do không có lệnh break giữa các case. Khi x = 0, lệnh case 0 và case 2 được thực hiện.

 

Thư viện tài liệu12 Tháng bảy, 2023 @ 2:52 chiều

Đánh giá chủ đề này