intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Đề thi trắc nghiệm lập trình C

Chia sẻ: Khoa CNTT DTU D15TMT | Ngày: | Loại File: DOC | Số trang:105

1.330
lượt xem
178
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tham khảo tài liệu 'đề thi trắc nghiệm lập trình c', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả

Chủ đề:
Lưu

Nội dung Text: Đề thi trắc nghiệm lập trình C

  1. BÀI THI TRẮC NGHIỆM ĐỀ SỐ: 501 1. What value is stored in x after the following two statements are executed: int x; x = 2 / 4 * 4 / 2; A 0 B 0.0625 C 1 D 1.0 2. Which of the following statements will correctly output the quote: Dan Quayle once said, "Who’s responsible for the riots? The rioters." A cout
  2. B C D 4. Which snippet of code correctly adds the odd integers between 1 and 20? A B
  3. C D 5. A B
  4. C D 6. Which of the following is an invalid comment? A // Comment regarding the program B /* Comment regarding the program */ C /************************** D /************************** * Comment about the program **************************/ 7. What data types can be used to store numeric values with a decimal point, such as 3.14 ? A short, int B long C float, double
  5. D char 8. A x = 1, y = 2 B x = 1, y = 1 C x = 0, y = 2 D x = 0, y = 1 9. What value is stored in variable x? int x; x = 2 * 3 + 4 * 5 -4 / 2; A 24 B 11 C 14 D 28
  6. 10. How can we input a value from the keyboard and store it in the variable named num? A cout > num; C cin using namespace std; B #include < stdlib.h> C #include < cstdlib> using namespace std; D #include < iostream> using namespace std; 12. Which of the following functions correctly returns the minimum of three integers passed in? A
  7. B C D 13.
  8. A 3223 B 3211 C 3212 D 3213 14.
  9. A X =1 Y = 1 B X =1 Y = 2 C X =2 Y = 1 D X =2 Y = 2 15. Which of the following function prototypes is equivalent to the following prototype? int min(int num1, int num2, int num3); A int min(long num1, long num2, long num3); B int min(int, int, int); C int min(double num1, double num2, double num3); D long min(int, int, int);
  10. 16. A Before foo, X=1 In foo, X=1, After foo, X=1 B Before foo, X=1 In foo, X=2, After foo, X=2 C Before foo, X=2 In foo, X=2, After foo, X=2 D Before foo, X=1 In foo, X=2, After foo, X=1 17.
  11. A 10 4 10 4 B 10 4 10 3 C 2 3 10 4 D 10 4 2 3 18.
  12. A 10 4 10 4 B 2 3 10 4 C 10 4 10 3 D 10 4 2 3 19.
  13. A X=3 Y=2 B X=3 Y=3 C X=2 Y=3 D X=2 Y=2 20. Given the following function prototype: void foo(int arr[]); Which statement correctly passes the array to the function? A int arr[10]; foo(arr);
  14. B int arr[10]; foo(arr[]); C int arr[10]; foo(arr[0]); D int arr[10]; foo(arr[10]); 21. Which of the following correctly declares an array that holds exactly 10 integers? A int[10] arr; B int[11] arr; C int arr[11]; D int arr[10]; 22. A 321
  15. B 121 C 311 D An error message 23. Which of the following is an invalid function prototype to accept a two- dimensional array of type double? A double foo(double arr[10][10]); B double foo(double arr[][10]); C double foo(double arr[10][100]); D double foo(double arr[][]); 24. A 12345
  16. B 54321 C 52341 D 52345 25. A 311 B 321 C 123 D 121 26.
  17. A int main(){ Foo f; f->printMessage(); return 0; } B int main(){ Foo f; f::printMessage(); return 0; } C int main() { Foo f; f.printMessage(); return 0; }
  18. int main(){ D Foo f; printMessage(); return 0; } 27. What is the error in the following definition? class BankAccount{ public: int ID; double amount; } A There are no methods B There are no private variables C There is a missing semicolon after the right curly brace. D There are no public accessor methods. 28. Given the following declaration, how do we access the x and y members of the structure? struct Point { int x; int y; }; A Point p; p->x = 10; p->y = 20; B Point p; p::x = 10; p::y = 20; C Point p; p.x = 10;
  19. p.y = 20; D Point p; p:x = 10; p:y = 20; 29. What is the error in the following definition? struct BankAccount{ int ID; double amount; } A "ID" cannot be all uppercase B The keyword "struct" should be "structure" C Different data types are not allowed in the struct. D There is a semicolon missing after the right curly brace 30. Under the principle of information hiding, which class definition best encapsulated the variable named "x"? A B
  20. C D 31.
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2