700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 14
Đề thi

700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 14

A
Admin
Đại họcTrắc nghiệm tổng hợp68 lượt thi
25 câu hỏi
1. Trắc nghiệm
• 1 điểm

What is output of following code? void main() { int ints[] = { 0, 1, 2, 3 }; int* i1 = ints + 1; int* i2 = ints + 2; int a = ++*i1 + *i2++; int b = *++i1 + *i2--; printf("%d#%d", a, b); getch(); }

4#4

4#5

5#6

4#6

Xem đáp án

Chọn đáp án B

2. Trắc nghiệm
• 1 điểm

What is output of following code? void main() { int i = 400; int *ptr = &i; *++ptr = 2; printf("%d %d", i, *ptr); getch(); }

400 2

400 400

400 401

Complier error

Xem đáp án

Chọn đáp án A

3. Trắc nghiệm
• 1 điểm

What is output? void main() { char str[] = {"pvpit"}; char *s1 = str; s1++; printf("%c", *s1); getch(); }

pvpit

vpit

v

Another

Xem đáp án

Chọn đáp án C

4. Trắc nghiệm
• 1 điểm

What is output? void main() { char *s = "\12345s\n"; printf("%d", strlen(s)); printf("\n%s", s); getch(); }

5

7

9

10

Xem đáp án

Chọn đáp án A

5. Trắc nghiệm
• 1 điểm

For the code below which lines should be reported as errors by a compiler? int main(int argc, char** argv) { const char* foo = "wow"; // line 1 foo = "top"; // line 2 foo[0] = 1; // line 3 return 0; }

1

2

3

None of the lines

Xem đáp án

Chọn đáp án C

6. Trắc nghiệm
• 1 điểm

What is output? void main() { int x = 5,y = 6; int* const p = &x; p = &y; printf("%d", (*p)); getch(); }

Complier error

6

5

Another

Xem đáp án

Chọn đáp án A

7. Trắc nghiệm
• 1 điểm

What is output? void main() { int x = 5, y = 8; const int* p; p = &x; p = &y; x++; printf("%d", *p); getch(); }

5

6

8

Complier Error

Xem đáp án

Chọn đáp án C

8. Trắc nghiệm
• 1 điểm

What is output of code? void main() { int x = 5; const int* p; p = &x; x++; *p = 4; printf("%d", *p); getch(); }

4

5

6

Complier Error

Xem đáp án

Chọn đáp án D

9. Trắc nghiệm
• 1 điểm

What is output of code? #include int main() { int a = 320; char *ptr; ptr = (char*)&a; printf("%d ", *ptr); return 0; }

320

64

Complier Error

Xem đáp án

Chọn đáp án B

10. Trắc nghiệm
• 1 điểm

What will be output of following program? #include int main() { int i = 3; int *j; int **k; j = &i; k = &j; printf("%u , %u , %d ", k, *k, **k); return 0; }

Address of j , Address of i , 3

Complier Error

3 , 3 , 3

Xem đáp án

Chọn đáp án A

11. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include #include int main() { char *ptr1 = NULL; char *ptr2 = 0; printf("\n%d", ptr2); strcpy(ptr1, "c"); strcpy(ptr2, "questions"); printf("\n%s %s", ptr1, ptr2); getch(); }

printf("\n%d", ptr2);

strcpy(ptr1, "c");

strcpy(ptr2, "questions");

printf("\n%s %s", ptr1, ptr2);

Xem đáp án

Chọn đáp án B

12. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include int main() { int a = 10; void *p = &a; int *ptr = p; printf("%u\n", *ptr); getch(); }

int a = 10;

void *p = &a;

int *ptr = p;

printf("%u\n", *ptr);

Xem đáp án

Chọn đáp án C

13. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include int main() { int a = 5, b = 10, c; int *p = &a, *q = &b; c = p - q; printf("%d" , c); getch(); }

3

4

5

6

Xem đáp án

Chọn đáp án A

14. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include int main() { int i = 5, j; int *p , *q; p = &i; q = &j; j = 5; printf("%d %d", *p, *q); getch(); }

5 5

Complier Error

5 Garbage value

Xem đáp án

Chọn đáp án A

15. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include void main() { int i = 5; int *p; p = &i; printf(" %u %u", *&p , &*p); getch(); }

Address of i Address of i

Garbage value Garbage value

Complier Error

Xem đáp án

Chọn đáp án A

16. Trắc nghiệm
• 1 điểm

What is output? #include #include int main() { int array[2][2][3]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; printf("%d", array[1][0][2]); getch(); }

6

7

8

9

Xem đáp án

Chọn đáp án C

17. Trắc nghiệm
• 1 điểm

What is output? #include #include void main() { char arr[8]={'V','I','E','T','N','A','M'}; char *p; p=(char *)(arr+2)[2]; printf("%c", p); getch(); }

I

E

M

N

Xem đáp án

Chọn đáp án D

18. Trắc nghiệm
• 1 điểm

What will be output of following program? #include #include void main() { char ch[]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; int *p = (int*)ch; p++; printf("%x", *p); getch(); }

37363534

34353637

45673333

Xem đáp án

Chọn đáp án A

19. Trắc nghiệm
• 1 điểm

What is output? #include #include int main() { int i = 11; int const * p = &i; p++; printf("%d", *p); getch(); }

11

12

Garbage value

Complier error

Xem đáp án

Chọn đáp án C

20. Trắc nghiệm
• 1 điểm

Which of the following statements are correct about an array? 1. The array int num[26]; can store 26 elements 2. The expression num[1] designates the very first element in the array 3. It is necessary to initialize the array at the time of declaration. 4. The declaration num[SIZE] is allowed if SIZE is a macro.

1,4

3

1,2

1

Xem đáp án

Chọn đáp án A

21. Trắc nghiệm
• 1 điểm

The library function used to find the last occurrence of a character in a string is

strnstr()

strrchr()

laststr()

strstr()

Xem đáp án

Chọn đáp án B

22. Trắc nghiệm
• 1 điểm

What is output? (assuming that the array begins at the location 1002 and size of an integer is 4 bytes) #include #include int main() { int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1)); getch(); }

1006, 2, 2

1006, 4, 4

1002, 5, 5

Error

Xem đáp án

Chọn đáp án A

23. Trắc nghiệm
• 1 điểm

What does the following declaration mean? int (*ptr)[10];

ptr is array of pointers to 10 integers

ptr is a pointer to an array of 10 integers

ptr is an array of 10 integers

ptr is an pointer to array

Xem đáp án

Chọn đáp án A

24. Trắc nghiệm
• 1 điểm

What is output? #include #include int main() { char str[] = "LAPTRINHC++\0\.NET\0"; printf("%s\n", str); getch(); }

LAPTRINHC++

LAPTRINHC++\0\.NET\0

LAPTRINHC++\0\.NET

Xem đáp án

Chọn đáp án A

25. Trắc nghiệm
• 1 điểm

What is output? #include #include void swap(char *, char *); int main() { char *pstr[2] = {"LAPTRINHC++", ".NET"}; swap(pstr[0], pstr[1]); printf("%s%s", pstr[0], pstr[1]); getch(); } void swap(char *t1, char *t2) { char *t; t=t1; t1=t2; t2=t; }

LAPTRINHC++.NET

NETLAPTRINHC++

Address of pstr[0] Address of pstr[1]

Xem đáp án

Chọn đáp án A

Bạn có thích hoạt động này không?

Bắt đầu ngay
Khám phá các nguồn tài nguyên miễn phí, phù hợp với tiêu chuẩn trong vài giây
Giải tích 1Giải tích 2Giải tích 3Cơ học kĩ thuậtKiến thức máy tínhNgôn ngữ lập trình CKĩ thuật đoTruyền động điệnKỹ thuật đo lườngNgắn mạch trong Hệ thống điệnToán tài chính đại cươngLý luận TDTTHóa lýHệ điều hành Unix (Linux)Kỹ thuật vi xử lýQuá trình và thiết bị chuyển khối (Hóa công 3)Quá trình và thiết bị truyền nhiệt (Hóa công 2)Phân tích thành phần lý hóa thực phẩmMáy điện IAnten và Truyền SóngCông nghệ Web và dịch vụ trực tuyếnHệ Điều hànhLuật hàng khôngLinux và phần mềm mã nguồn mởCấu tạo ô tôChế tạo phôiMáy nâng chuyểnCông nghệ khung vỏ ô tôCấu trúc máy tínhThông tin di độngThiết kế VLSIHệ thống thông tin y tếCông nghệ sản xuất giấyCông nghệ sinh học trong hoá dượcHoá dược & KT tổng hợp 1Bơm quạt máy nénKỹ thuật mạngTương tác Người – MáyPhân tích yêu cầu phần mềmQuản trị cơ sở dữ liệu phân tánNgôn ngữ mô hình hóa UMLCác kỹ thuật chuyển mạchKỹ thuật cháyCông nghệ lên men công nghiệpCông nghệ sinh học thực vậtHóa học IIQuá trình và thiết bị cơ họcKĩ thuật thủy khíKĩ thuật điện tử sốMáy điện 2Thiết bị điệnCơ sở tự động hóaCung cấp điệnHệ thống thông tin công nghiệpLý thuyết thông tinXử lý số tín hiệuCơ sở đo lường điện tửProfessional skillsNhững NLCB của CN Mác-Lênin I (Tự luận)Tư tưởng Hồ Chí Minh (Tự luận)Đường lối CM của Đảng CSVN (Tự luận)Pháp luật đại cương (Tự luận)Bơi lội (Tự luận)Đường lối quân sự của Đảng (Tự luận)Công tác quốc phòng, an ninh (Tự luận)