50 CÂU HỎI
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.
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
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.
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++
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 ;
Lệnh cout trong C++ đi kèm với cặp dấu nào?
A. >>
B. \\
C. ||
D. <<
Để 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. >>
Để 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. <<
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++
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>
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
What is the only function all C programs must contain?
A. start()
B. system()
C. main()
D. program()
What punctuation is used to signal the beginning and end of code blocks?
A. { }
B. → and ←
C. BEGIN and END
D. ( and )
What punctuation ends most lines of C code?
A. .
B. ;
C.
Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }
Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double
Which of the following is the correct operator to compare two variables?
A. :=
B. =
C. equal
D. ==
Which of the following is true?
A. 1
B. 66
C. -1
D. All of the above
Which of the following is the boolean operator for logical-and?
A. &
B. &&
C. |
D. |&
Evaluate !(1 && !(0 || 1))
A. True
B. False
C. Unevaluatable
Which of the following shows the correct syntax for an if statement?
A. if expression
B. if { expression
C. if ( expression )
D. expression if
What is the final value of x when the code is run?
A. 10
B. 9
C. 0
D. 1
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
Which is not a loop structure?
A. for
B. do while
C. while
D. repeat until
How many times is a do while loop guaranteed to loop?
A. 0
B. Infinitely
C. 1
D. Variable
Which is not a proper prototype?
A. int funct(char x, char y);
B. double funct(char x)
C. void funct();
D. char x();
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
Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();
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” ); }
What is required to avoid falling through from one case to the next?
A. end;
B. break;
C. stop;
D. continue;
What keyword covers unhandled possibilities?
A. all
B. continue
C. default
D. other
What is the result of the following code?
A. One
B. Zero
C. Hello World
D. ZeroHello World
Which of the following is the proper declaration of a pointer?
A. int x;
B. int &x;
C. ptr x;
D. int *x;
Which of the following gives the memory address of integer variable a?
A. *a;
B. a;
C. &a;
D. address(a);
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);
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;
Which of the following is the proper keyword or function to allocate memory in C?
A. new
B. malloc
C. create
D. value
Which of the following is the proper keyword or function to deallocate memory in C language?
A. free
B. delete
C. clear
D. remove
Which of the following accesses a variable in structure b?
A. b→var;
B. b.var;
C. b-var;
D. b>var;
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;
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;};
Which properly declares a variable of struct foo?
A. struct foo;
B. struct foo var;
C. foo;
D. int foo;
Which of the following correctly declares an array?
A. int arr[10];
B. int arr;
C. arr{10};
D. array arr[10];
What is the index number of the last element of an array with 29 elements?
A. 29
B. 28
C. 0
D. Programmer-defined
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];
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;
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];
Which of the following is a string literal?
A. Static String
B. “Static String”
C. ‘Static String’
D. char string[100];
What character ends all strings?
A. ‘.’
B. ‘ ‘
C. ‘\0’
D. ‘/0’
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);