vietjack.com

400 Câu hỏi trắc nghiệm lập trình C/C++ có đáp án (Phần 1)
Quiz

400 Câu hỏi trắc nghiệm lập trình C/C++ có đáp án (Phần 1)

P
Phuoc Ngo
50 câu hỏiIT TestTrắc nghiệm tổng hợp
50 CÂU HỎI
1. Nhiều lựa chọn

Trong cấu trúc chương trình C++, lệnh #include dùng để làm gì?

A. Thông báo trong chương trình sử dụng các lệnh tính toán, thông báo các biến sử dụng trong thân chương trình.

B. Khai báo các câu lệnh được sử dụng trong chương trình. Phải tạo các câu lệnh trước thì mới sử dụng được trong chương trình C++.

C. Thông báo cho bộ tiền biên dịch thêm các thư viện chuẩn trong C++. Các lệnh được sử dụng trong thân chương trình phải có prototype nằm trong các thư viện chuẩn này.

D. Không có đáp án đúng.

2. Nhiều lựa chọn

Trong cấu trúc chương trình C++ có bao nhiêu hàm main()?

A. 1

B. 2

C. 3

D. 4

3. Nhiều lựa chọn

Lệnh cout trong C++ có tác dụng gì?

A. Là stream đầu ra chuẩn trong C++.

B. Là lệnh chú thích trong C++

C. Là stream đầu vào chuẩn của C++.

D. Là lệnh khai báo một biến.

4. Nhiều lựa chọn

Lệnh cin trong C++ có tác dụng gì?

A. Là lệnh chú thích trong C++

B. Là lệnh khai báo một biến.

C. Là stream đầu ra chuẩn trong C++.

D. Là stream đầu vào chuẩn của C++

5. Nhiều lựa chọn

Kết thúc một dòng lệnh trong chương trình C++, ta sử dụng ký hiệu gì?

A. Dấu ,

B. Dấu .

C. Dấu :

D. Dấu ;

6. Nhiều lựa chọn

Lệnh cout trong C++ đi kèm với cặp dấu nào?

A. >>

B. \\

C. ||

D. <<

7. Nhiều lựa chọn

Để chú thích trên 1 dòng lệnh trong chương trình C++, ta dùng cặp dấu nào?

A. \* và *\

B. <<

C. //

D. >>

8. Nhiều lựa chọn

Để chú thích trên nhiều dòng lệnh trong chương trình C++, ta dùng cặp dấu nào?

A. \\

B. >>

C. /* và */

D. <<

9. Nhiều lựa chọn

Chú thích nào sau đây là chính xác?

A. \*Lập trình C++

B. //Lập trình C++

C. <!-Lập trình C++-->

D. \\Lập trình C++

10. Nhiều lựa chọn

Cách khai báo biến nào sau đây là đúng?

A. <kiểu dữ="" liệu="">;

B. : <kiểu dữ="" liệu="">;

C. <tên biến=""> = <giá trị="">;

D. Tất cả đầu không đúng</giá></tên></kiểu></kiểu>

11. Nhiều lựa chọn

What is the correct value to return to the operating system upon the successful completion of a program?

A. 0

B. -1

C. 1

D. Do not return a value

12. Nhiều lựa chọn

What is the only function all C programs must contain?

A. start()

B. system()

C. main()

D. program()

13. Nhiều lựa chọn

What punctuation is used to signal the beginning and end of code blocks?

A. { }

B. → and ←

C. BEGIN and END

D. ( and )

14. Nhiều lựa chọn

What punctuation ends most lines of C code?

A. .

B. ;

C.

15. Nhiều lựa chọn

Which of the following is a correct comment?

A. */ Comments */

B. ** Comment **

C. /* Comment */

D. { Comment }

16. Nhiều lựa chọn

Which of the following is not a correct variable type?

A. float

B. real

C. int

D. double

17. Nhiều lựa chọn

Which of the following is the correct operator to compare two variables?

A. :=

B. =

C. equal

D. ==

18. Nhiều lựa chọn

Which of the following is true?

A. 1

B. 66

C. -1

D. All of the above

19. Nhiều lựa chọn

Which of the following is the boolean operator for logical-and?

A. &

B. &&

C. |

D. |&

20. Nhiều lựa chọn

Evaluate !(1 && !(0 || 1))

A. True

B. False

C. Unevaluatable

21. Nhiều lựa chọn

Which of the following shows the correct syntax for an if statement?

A. if expression

B. if { expression

C. if ( expression )

D. expression if

22. Nhiều lựa chọn

What is the final value of x when the code is run? Media VietJack

A. 10

B. 9

C. 0

D. 1

23. Nhiều lựa chọn

When does the code block following while(x<100) execute?

A. When x is less than one hundred

B. When x is greater than one hundred

C. When x is equal to one hundred

D. While it wishes

24. Nhiều lựa chọn

Which is not a loop structure?

A. for

B. do while

C. while

D. repeat until

25. Nhiều lựa chọn

How many times is a do while loop guaranteed to loop?

A. 0

B. Infinitely

C. 1

D. Variable

26. Nhiều lựa chọn

Which is not a proper prototype?

A. int funct(char x, char y);

B. double funct(char x)

C. void funct();

D. char x();

27. Nhiều lựa chọn

What is the return type of the function with prototype: “int func(char x, float v, double t);”

A. char

B. int

C. float

D. double

28. Nhiều lựa chọn

Which of the following is a valid function call (assuming the function exists)?

A. funct;

B. funct x, y;

C. funct();

D. int funct();

29. Nhiều lựa chọn

Which of the following is a complete function?

A. int funct();

B. int funct(int x) {return x=x+1;}

C. void funct(int) {printf( “Hello” );

D. void funct(x) {printf( “Hello” ); }

30. Nhiều lựa chọn

What is required to avoid falling through from one case to the next?

A. end;

B. break;

C. stop;

D. continue;

31. Nhiều lựa chọn

What keyword covers unhandled possibilities?

A. all

B. continue

C. default

D. other

32. Nhiều lựa chọn

What is the result of the following code? Media VietJack

A. One

B. Zero

C. Hello World

D. ZeroHello World

33. Nhiều lựa chọn

Which of the following is the proper declaration of a pointer?

A. int x;

B. int &x;

C. ptr x;

D. int *x;

34. Nhiều lựa chọn

Which of the following gives the memory address of integer variable a?

A. *a;

B. a;

C. &a;

D. address(a);

35. Nhiều lựa chọn

Which of the following gives the memory address of a variable pointed to by pointer a?

A. a;

B. *a;

C. &a;

D. address(a);

36. Nhiều lựa chọn

Which of the following gives the value stored at the address pointed to by pointer a?

A. a;

B. val(a);

C. *a;

D. &a;

37. Nhiều lựa chọn

Which of the following is the proper keyword or function to allocate memory in C?

A. new

B. malloc

C. create

D. value

38. Nhiều lựa chọn

Which of the following is the proper keyword or function to deallocate memory in C language?

A. free

B. delete

C. clear

D. remove

39. Nhiều lựa chọn

Which of the following accesses a variable in structure b?

A. b→var;

B. b.var;

C. b-var;

D. b>var;

40. Nhiều lựa chọn

Which of the following accesses a variable in a pointer to a structure, *b?

A. b→var;

B. b.var;

C. b-var;

D. b>var;

41. Nhiều lựa chọn

Which of the following is a properly defined struct?

A. struct {int a;}

B. struct a_struct {int a;}

C. struct a_struct int a;

D. struct a_struct {int a;};

42. Nhiều lựa chọn

Which properly declares a variable of struct foo?

A. struct foo;

B. struct foo var;

C. foo;

D. int foo;

43. Nhiều lựa chọn

Which of the following correctly declares an array?

A. int arr[10];

B. int arr;

C. arr{10};

D. array arr[10];

44. Nhiều lựa chọn

What is the index number of the last element of an array with 29 elements?

A. 29

B. 28

C. 0

D. Programmer-defined

45. Nhiều lựa chọn

Which of the following is a two-dimensional array?

A. array arr[20][20];

B. int arr[20][20];

C. int arr[20, 20];

D. char arr[20];

46. Nhiều lựa chọn

Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?

A. foo[6];

B. foo[7];

C. foo(7);

D. foo;

47. Nhiều lựa chọn

Which of the following gives the memory address of the first element in array arr, an array with 100 elements?

A. arr[0];

B. arr;

C. &arr;

D. arr[1];

48. Nhiều lựa chọn

Which of the following is a string literal?

A. Static String

B. “Static String”

C. ‘Static String’

D. char string[100];

49. Nhiều lựa chọn

What character ends all strings?

A. ‘.’

B. ‘ ‘

C. ‘\0’

D. ‘/0’

50. Nhiều lựa chọn

Which of the following reads in a string named x with one hundred characters?

A. fgets(x, 101, stdin);

B. fgets(x, 100, stdin);

C. readline(x, 100, ‘\n’);

D. read(x);

© All rights reserved VietJack