Ngân hàng câu hỏi trắc nghiệm C++ có đáp án

Để củng cố các kiến thức đã học về C++, eLib mời bạn đọc cùng thử sức với một số câu hỏi trắc nghiệm C++ dưới đây. Hy vọng, các câu hỏi đơn giản này sẽ không làm khó được bạn. 

Ngân hàng câu hỏi trắc nghiệm C++ có đáp án

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

2. What is the only function all C programs must contain?
A. start()
B. system()
C. main()
D. program()

3. What punctuation is used to signal the beginning and end of code blocks? 
A. { }
B.→ and ←
C. BEGIN and END
D. ( and )

4. What punctuation ends most lines of C code?
A. .
B. ;
C. :
D. ‘

5. Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }

6. Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double

7. Which of the following is the correct operator to compare two variables?
A. :=
B. =
C. equal
D. ==

8. Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above

9. Which of the following is the boolean operator for logical-and?
A. &
B. &&
C. |
D. |&

10. Evaluate !(1 && !(0 || 1))
A. True
B. False
C. Unevaluatable

11. Which of the following shows the correct syntax for an if statement?
A. if expression
B. if { expression
C. if ( expression )
D. expression if

12. What is the final value of x when the code is run?

nt x;
for(x = 0; x < 10; x++) { }

A. 10

B. 9

C. 0

D. 1

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

14. Which is not a loop structure?
A. for
B. do while
C. while
D. repeat until

15. How many times is a do while loop guaranteed to loop?
A. 0
B. Infinitely
C. 1
D. Variable

16. Which is not a proper prototype?
A. int funct(char x, char y);
B. double funct(char x)
C. void funct();
D. char x();

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

18.  Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();

19. 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” ); }

20. Which follows the case statement?
A. :
B. ;
C. –
D. A newline

21. What is required to avoid falling through from one case to the next?
A. end;
B. break;
C. stop;
D. continue;

22. What keyword covers unhandled possibilities?
A. all
B. continue
C. default
D. other

23. What is the result of the following code?

#include <stdio.h>
void main()
{
    int x = 0;
    switch(x)
    {
    case 1: printf( "One" );
    case 0: printf( "Zero" );
    case 2: printf( "Hello World" );
    }
}

A. One
B. Zero
C. Hello World
D. ZeroHello World

24. Which of the following is the proper declaration of a pointer?
A. int x;
B. int &x;
C. ptr x;
D. int *x;

25. Which of the following gives the memory address of integer variable a?
A. *a;
B. a;
C. &a;
D. address(a);

26. 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);

27. 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;

28. Which of the following is the proper keyword or function to allocate memory in C?
A. new
B. malloc
C. create
D. value

29. Which of the following is the proper keyword or function to deallocate memory in  C language?
A. free
B. delete
C. clear
D. remove

30. Which of the following accesses a variable in structure b?
A. b→var;
B. b.var;
C. b-var;
D. b>var;

Mời các bạn bấm nút TẢI VỀ hoặc XEM ONLINE để tham khảo đầy đủ Ngân Hàng Câu hỏi trắc nghiệm PHP có đáp án!

Để củng cố kiến thức và nắm vững nội dung, mời các bạn cùng làm bộ câu hỏi trắc nghiệm "400 câu hỏi trắc nghiệm lập trình C++ có đáp án và lời giải chi tiết"

Trắc Nghiệm

Ngày:30/10/2020 Chia sẻ bởi:Nguyễn Minh Duy

CÓ THỂ BẠN QUAN TÂM