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

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

A
Admin
IT TestTrắc nghiệm tổng hợp92 lượt thi
50 câu hỏi
1. Trắc nghiệm
1 điểm

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

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.

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++.

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.

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

Xem đáp án

Chọn C

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

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

1

2

3

4

Xem đáp án

Chọn A

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

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

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

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

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

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

Xem đáp án

Chọn A

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

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

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

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

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

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

Xem đáp án

Chọn D

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

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

Dấu ,

Dấu .

Dấu :

Dấu ;

Xem đáp án

Chọn D

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

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

>>

\\

||

<<

Xem đáp án

Chọn D

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

Để 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?

\* và *\

<<

//

>>

Xem đáp án

Chọn C

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

Để 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?

\\

>>

/* và */

<<

Xem đáp án

Chọn C

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

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

\*Lập trình C++

//Lập trình C++

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

\\Lập trình C++

Xem đáp án

Chọn B

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

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

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

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

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

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

Xem đáp án

Chọn A

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

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

0

-1

1

Do not return a value

Xem đáp án

Chọn A

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

What is the only function all C programs must contain?

start()

system()

main()

program()

Xem đáp án

Chọn C

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

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

{ }

→ and ←

BEGIN and END

( and )

Xem đáp án

Chọn A

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

What punctuation ends most lines of C code?

A. .

B. ;

C.

Xem đáp án

Chọn B

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

Which of the following is a correct comment?

*/ Comments */

** Comment **

/* Comment */

{ Comment }

Xem đáp án

Chọn C

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

Which of the following is not a correct variable type?

float

real

int

double

Xem đáp án

Chọn B

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

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

=

=

equal

==

Xem đáp án

Chọn D

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

Which of the following is true?

1

66

-1

All of the above

Xem đáp án

Chọn D

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

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

&

&&

|

|&

Xem đáp án

Chọn B

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

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

True

False

Unevaluatable

Xem đáp án

Chọn A

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

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

if expression

if { expression

if ( expression )

expression if

Xem đáp án

Chọn C

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

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

10

9

0

1

Xem đáp án

Chọn A

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

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

When x is less than one hundred

When x is greater than one hundred

When x is equal to one hundred

While it wishes

Xem đáp án

Chọn A

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

Which is not a loop structure?

for

do while

while

repeat until

Xem đáp án

Chọn D

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

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

0

Infinitely

1

Variable

Xem đáp án

Chọn C

26. Trắc nghiệm
1 điểm

Which is not a proper prototype?

int funct(char x, char y);

double funct(char x)

void funct();

char x();

Xem đáp án

Chọn B

27. Trắc nghiệm
1 điểm

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

char

int

float

double

Xem đáp án

Chọn B

28. Trắc nghiệm
1 điểm

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

funct;

funct x, y;

funct();

int funct();

Xem đáp án

Chọn C

29. Trắc nghiệm
1 điểm

Which of the following is a complete function?

int funct();

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

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

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

Xem đáp án

Chọn B

30. Trắc nghiệm
1 điểm

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

end;

break;

stop;

continue;

Xem đáp án

Chọn B

31. Trắc nghiệm
1 điểm

What keyword covers unhandled possibilities?

all

continue

default

other

Xem đáp án

Chọn C

32. Trắc nghiệm
1 điểm

What is the result of the following code?Media VietJack

One

Zero

Hello World

ZeroHello World

Xem đáp án

Chọn D

33. Trắc nghiệm
1 điểm

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

int x;

int &x;

ptr x;

int *x;

Xem đáp án

Chọn D

34. Trắc nghiệm
1 điểm

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

*a;

a;

&a;

address(a);

Xem đáp án

Chọn C

35. Trắc nghiệm
1 điểm

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

a;

*a;

&a;

address(a);

Xem đáp án

Chọn A

36. Trắc nghiệm
1 điểm

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

a;

val(a);

*a;

&a;

Xem đáp án

Chọn C

37. Trắc nghiệm
1 điểm

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

new

malloc

create

value

Xem đáp án

Chọn B

38. Trắc nghiệm
1 điểm

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

free

delete

clear

remove

Xem đáp án

Chọn B

39. Trắc nghiệm
1 điểm

Which of the following accesses a variable in structure b?

b→var;

b.var;

b-var;

b>var;

Xem đáp án

Chọn B

40. Trắc nghiệm
1 điểm

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

b→var;

b.var;

b-var;

b>var;

Xem đáp án

Chọn A

41. Trắc nghiệm
1 điểm

Which of the following is a properly defined struct?

struct {int a;}

struct a_struct {int a;}

struct a_struct int a;

struct a_struct {int a;};

Xem đáp án

Chọn D

42. Trắc nghiệm
1 điểm

Which properly declares a variable of struct foo?

struct foo;

struct foo var;

foo;

int foo;

Xem đáp án

Chọn B

43. Trắc nghiệm
1 điểm

Which of the following correctly declares an array?

int arr[10];

int arr;

arr{10};

array arr[10];

Xem đáp án

Chọn A

44. Trắc nghiệm
1 điểm

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

29

28

0

Programmer-defined

Xem đáp án

Chọn B

45. Trắc nghiệm
1 điểm

Which of the following is a two-dimensional array?

array arr[20][20];

int arr[20][20];

int arr[20, 20];

char arr[20];

Xem đáp án

Chọn B

46. Trắc nghiệm
1 điểm

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

foo[6];

foo[7];

foo(7);

foo;

Xem đáp án

Chọn A

47. Trắc nghiệm
1 điểm

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

arr[0];

arr;

&arr;

arr[1];

Xem đáp án

Chọn B

48. Trắc nghiệm
1 điểm

Which of the following is a string literal?

Static String

“Static String”

‘Static String’

char string[100];

Xem đáp án

Chọn B

49. Trắc nghiệm
1 điểm

What character ends all strings?

‘.’

‘ ‘

‘\0’

‘/0’

Xem đáp án

Chọn C

50. Trắc nghiệm
1 điểm

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

fgets(x, 101, stdin);

fgets(x, 100, stdin);

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

read(x);

Xem đáp án

Chọn B