#include #include void main() { int a[5] = {1, 2}; printf(“%d %d %d”, a[2], a[3], a[4]); getch(); } What is output of program?

#include

#include

void main()

{

int a[5] = {1, 2};

printf(“%d %d %d”, a[2], a[3], a[4]);

getch();

}

What is output of program?

A. 0 0 0

B. 1 2 2

C. 1 1 1

D. Error

Hướng dẫn

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

Xem lời giải

Xem lời giải

Đối với mảng tĩnh, nếu khởi tạo thiếu cho các phần tử thì mặc định các phần tử đó được gán bằng 0.

Hay nói cách khác, câu lệnh int a[5] = {1,2}; int a[5] = {1, 2, 0, 0, 0};

 

Thư viện tài liệu12 Tháng bảy, 2023 @ 2:59 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