void main() { int x; if(x = 0) printf (“Value of x is 0”); else printf (“Value of x is not 0”); getch(); } What gets printed?

void main()

{

int x;

if(x = 0)

printf (“Value of x is 0”);

else

printf (“Value of x is not 0”);

getch();

}

What gets printed?

A. Value of x is 0

B. Value of x is not 0

C. Error

Hướng dẫn

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

Xem lời giải

Xem lời giải

Vì biểu thức x=0 của lệnh if(x=0) là phép gán 0 cho biến x mà ko phải biểu thức so sánh. Biểu thức gán này có giá trị là 0 nên câu lệnh của else sẽ được thực hiện.

 

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

Đánh giá chủ đề này
How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site