Tuyển tập đề thi trắc nghiệm lập trình C HAY

42 1.7K 2
Tuyển tập đề thi trắc nghiệm lập trình C HAY

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Tổng hợp hơn 500 câu hỏi trắc nghiệm lập trình C chia thành các chương:1. Khái niệm cơ bản ngôn ngữ lập trình C; 2. Biến,toán tử và biểu thức toán học; 3. Vòng lặp for, do..while; 4. Ifelse , switch( ) case , goto; 5. Con trỏ,mảng,string; 6. Struct,union,enum; 8. Macro.phục vụ tốt cho các bạn sinh viên, các bạn đang có dự định thi tuyển vào các công ty phần mềm như: Fsoft, GameLoft, Tinh Vân, BKAV,...

Trắc nghiệm lập trình C vncoding.net Page 1 Title : Trắc nghiệm lập trình C Author : Vu Hong Viet Date : 07/09/2014 Các câu hỏi trắc nghiệm được thành viên diễn đàn vncoding sưu tập và biên soạn dựa trên quá trình học tập và kinh nghiệm thực tế. Chúng tôi đã chủ định biên soạn các câu hỏi trắc nghiệm bằng tiếng anh, vì đa số các đề thi trắc nghiệm lập trình vào các công ty phần mềm bằng tiếng anh. Đáp án được giải thích chi tiết tại diễn đàn: http://vncoding.net/forum/forumdisplay.php?f=18 1. Khái niệm cơ bản ngôn ngữ lập trình C 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 */ Trắc nghiệm lập trình C vncoding.net Page 2 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 int x; for(x=0; x<10; x++) {} is run? A. 10 B. 9 C. 0 D. 1 13. When does the code block following while(x<100) execute? Trắc nghiệm lập trình C vncoding.net Page 3 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. - Trắc nghiệm lập trình C vncoding.net Page 4 D. A newline 21. What is required to avoid falling through from one case to the next? A. end; B. break; C. Stop; D. A semicolon. 22. What keyword covers unhandled possibilities? A. all B. contingency C. default D. other 23. What is the result of the following code? Code: 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; Trắc nghiệm lập trình C vncoding.net Page 5 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? 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; 31. 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; 32. 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;}; 33. Which properly declares a variable of struct foo? A. struct foo; B. struct foo var; C. foo; D. int foo; Trắc nghiệm lập trình C vncoding.net Page 6 34. Which of the following correctly declares an array? A. int anarray[10]; B. int anarray; C. anarray{10}; D. array anarray[10]; 35. What is the index number of the last element of an array with 29 elements? A. 29 B. 28 C. 0 D. Programmer-defined 36. Which of the following is a two-dimensional array? A. array anarray[20][20]; B. int anarray[20][20]; C. int array[20, 20]; D. char array[20]; 37. 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; 38. Which of the following gives the memory address of the first element in array foo, an array with 100 elements? A. foo[0]; B. foo; C. &foo; D. foo[1]; 39. Which of the following is a string literal? A. Static String B. "Static String" C. 'Static String' D. char string[100]; 40. What character ends all strings? A. '.' B. ' ' C. '\0' D. '/0' 41. Which of the following reads in a string named x with one hundred characters? Trắc nghiệm lập trình C vncoding.net Page 7 A. fgets(x, 101, stdin); B. fgets(x, 100, stdin); C. readline(x, 100, '\n'); D. read(x); 42. Which of the following functions compares two strings? A. compare(); B. stringcompare(); C. cmp(); D. strcmp(); 43. Which of the following adds one string to the end of another? A. append(); B. stringadd(); C. strcat(); D. stradd(); 2. Biến, toán tử và biểu thức toán học 1. What will be output when you will execute following c code? Code: #include<stdio.h> int main(){ printf("%d\t",sizeof(6.5)); printf("%d\t",sizeof(90000)); printf("%d",sizeof('A')); return 0; } Biết kích thước kiểu char : 1 byte, float : 4 byte, int : 4 byte, double : 8 byte, long : 4 byte. A. 8 4 1 B. 8 2 1 C. 4 4 1 D. Depend on complier 2. What will be output when you will execute following c code? Code: #include<stdio.h> int main(){ double num=5.2; int var=5; printf("%d\t",sizeof(!num)); printf("%d\t",sizeof(var=15/2)); printf("%d",var); return 0; } Trắc nghiệm lập trình C vncoding.net Page 8 A. 1 4 5 B. 1 4 7 C. 8 4 7 D. Another 3. What value gets printed by the program below? Code: int w = 3; int x = 31; int y = 10; double z = x / y % w; printf("%f\n", z); A. 1 B. 0 C. 0.1 4. What will be output when you will execute following c code? Code: #include<stdio.h> int main(){ char a=250; int expr; expr= a+ !a + ~a + ++a; printf("%d",expr); return 0; } A. - 6 B. 4 C. 5 D. Another 5. What will be output when you will execute following c code? Code: #include<stdio.h> int main(){ int a=-5; unsigned int b=-5u; // (*) if(a==b) printf("Avatar"); else printf("Alien"); return 0; } A. Avatar B. Alien C. Error at (*) Trắc nghiệm lập trình C vncoding.net Page 9 D. Another 6. What will be output when you will execute following c code? Code: #include <stdio.h> #include <conio.h> void main() { int x = 3; printf("%d", x++ + ++x); getch(); } A. 7 B. 8 C. 9 D. Another 7. What output is? Code: void main() { int i=5,j=6,k; k=i&j; printf("%d",k); getch(); } A. 4 B. 0 C. 1 D. 5 8. What output is? Code: void main() { int i=5,j=6; printf("%d", i | j); getch(); } A. 7 B. 6 C. 5 D. 1 9. Output of following code: Trắc nghiệm lập trình C vncoding.net Page 10 Code: #include<stdio.h> #include "conio.h" extern int x=0; void main() { x++; printf("%d",x); getch(); } A. 0 B. Error C. 1 D. x isn't defined 10. Output of following code: Code: extern int x=0; void main() { { int x=1; } printf("%d",x); getch(); } A. 0 B. 1 C. Error Comlier 11. Output of following code: Code: int y=0; void main() { { int x=0; x++; ++y; } printf("%d\t%d",x,y); getch(); } A. 1 1 B. 1 0 C. 'x' undeclared identifier [...]... 15 C 15 10 5 D Run time error 17 What output is? Code: #include int main(){ asm{ mov bx,8; mov cx,10 add bx,cx; } printf("%d",_BX); return 0; vncoding.net Page 12 Tr c nghiệm lập trình C } A 18 B 8 C 0 D Complie error 18 What output is? Code: #include int main(){ char *url= "c: \tc\bin\rw .c" ; printf("%s",url); return 0; } A c: \tc\bin\rw .c B c: /tc/bin/rw .c C c: c inw .c D c: cinw .c E w .c. .. { int check = 20, arr[] = {10, 20, 30}; switch (check) { case arr[0]: printf("A "); case arr[1]: printf("B"); case arr[2]: printf( "C" ); } getch(); } A ABC B BC C B D Complier Error 5 Con trỏ,mảng,string 1 What output is? Code: void myfunc(char** param) vncoding.net Page 29 Tr c nghiệm lập trình C { ++param; } void main() { char* string = (char*)malloc(64); strcpy(string, "hello_World"); myfunc(&string);... output is? Code: #include int main(){ const int i=5; i++; printf("%d",i); return 0; } A 5 B 6 C 0 D Complier error 20 What output is? Code: #include #include void main() { char c= 125; c= c+10; printf("%d" ,c) ; getch(); } vncoding.net Page 13 Tr c nghiệm lập trình C A 135 B 8 C -121 D 121 21 What output is? Code: #include #include int main() { char c= 48; int... Error C 1 16 How many times will "vncoding" is printed on screen? Code: #include #include int main() { int i = 1024; for (; i; i >>= 1) printf("\nvncoding"); getch(); } A 10 B 11 vncoding.net Page 20 Tr c nghiệm lập trình C C Infinite 17 What output is? Code: #include #include void main() { int i=2,j=2; while(i+1? i:j++) printf("%d",i); getch(); } A 1 B 2 C Complier... default: a = 4; case 6: a ; case 5: a = a+1; case 1: a = a-1; } printf("%d \n", a); getch(); } A 5 B 4 vncoding.net Page 28 Tr c nghiệm lập trình C C 3 18 What output is? Code: #include #include int main() { int x = 3; if (x == 2); x = 0; if (x == 3) x++; else x += 2; printf("x = %d", x); getch(); } A x = 2 B x = 6 C x = 0 19 What output is? Code: #include #include ... loop C Complie error D Another 12 What output is? Code: void main() { int a=15,b=10 ,c= 5; if(a>b >c ) printf("True"); else printf("False"); getch(); } A True B False C Complier Error D Run time error 13 What output is? Code: #include #include void main() { int i = 0; switch (i) { case '0': printf("A"); break; case '1': printf("B"); vncoding.net Page 26 Tr c nghiệm lập trình C break;... printf(" %c" , c| mask); mask = mask . nghiệm lập trình C vncoding. net Page 1 Title : Trắc nghiệm lập trình C Author : Vu Hong Viet Date : 07/09/2014 Các câu hỏi trắc nghiệm được thành viên diễn đàn vncoding sưu tập và biên. will " ;vncoding& quot; is printed on screen? Code: #include <stdio.h> #include <conio.h> int main() { int i = 1024; for (; i; i >>= 1) printf(" vncoding");. correct comment? A. */ Comments */ B. ** Comment ** C. /* Comment */ Trắc nghiệm lập trình C vncoding. net Page 2 D. { Comment } 6. Which of the following is not a correct variable type?

Ngày đăng: 22/10/2014, 18:34

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan