Đăng ký Đăng nhập

Tài liệu Trắc nghiệm lập trình c

.PDF
42
765
66

Mô tả:

Trắc nghiệm lập trình C 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 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; vncoding.net Page 5 Trắc nghiệm lập trình C 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? vncoding.net Page 6 Trắc nghiệm lập trình C 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 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 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; } vncoding.net Page 7 Trắc nghiệm lập trình C 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 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 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 (*) vncoding.net Page 8 Trắc nghiệm lập trình C D. Another 6. What will be output when you will execute following c code? Code: #include #include void main() { int x = 3; printf("%d", x++ getch(); } + ++x); 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: vncoding.net Page 9 Trắc nghiệm lập trình C Code: #include #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 vncoding.net Page 10 Trắc nghiệm lập trình C 12. Output of following code: Code: void main() { int x; { x++; } printf("%d",x); getch(); } A. 1 B. 0 C. Error 13. Output of following code: Code: void main() { int x=0; { int x=0,y=0; y++; x++; } printf("%d",x); getch(); } A. 1 B. Error C. 0 14. Output of following code: Code: void count() { static int page=0; printf("%d",page); page++; } void main() { int i; for(i=0;i<10;i++) { count(); } vncoding.net Page 11 Trắc nghiệm lập trình C getch(); } A. 0123456789 B. 0000000000 C. 0101010101 15. Output of following code: Code: const int x = 5; void main() { int x[x]; int y = sizeof(x) / sizeof(int); printf("%d",y); getch(); } A. 1 B. 5 C. 20 D. 'x' isn't defined 16. What output is? Code: #include int main(){ int x=5,y=10,z=15; printf("%d %d %d"); return 0; } A. Garbage Garbage Garbage B. 5 10 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 in 19. What 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 i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } getch(); } A. 12480 B. 1248@ C. 12500 D. 12522 22. What output is? Code: #include #include int main() { float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n"); getch(); } A. Hi B. Hello C. None of above 3. Vòng lặp for, do..while 1. What value is returned by function func? Code: vncoding.net Page 14 Trắc nghiệm lập trình C float func() { int r = 0, d = 0, i=0; for (i; i < 2; i++) { r += 5 / d; } return r; } A. 5 B. 0 C. Exception D. Another 2.What will be output when you will execute following c code? Code: void main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("%c%c%c%c\t",s[ i ],*(s+i),*(i+s),i[s]); getch(); } A. mmmm aaaa nnnn B. mmm aaa nnn C. mmmm aaa nnn D. Another 3. What will be output when you will execute following c code? Code: void main() { int i = 0; char ch = 'A'; do { putchar (ch); } while(i++ < 5 || ++ch <= 'F'); getch(); } A. AAAAAABCDEF B. AAAAAABCDE C. ABCDEF D. Another vncoding.net Page 15 Trắc nghiệm lập trình C 4. What gets printed? Code: void main() { int array[2][2] = {0, 1, 2, 3}; int i; int sum = 0; for (i =0; i < 4; ++i) { int x, y; x = i % 2; if (x) { y = 0; } else { y = 1; } sum += array[x][y]; } printf("%d\n", sum); getch(); } A. 4 B. 5 C. 6 D. 3 5. What output is? Code: #include #include void main() { int k; for (k = -3; k < -5; k++) printf("Hello"); getch(); } A. Hello B. Nothing C. Complier Error D. Run time error 6. What output is? Code: vncoding.net Page 16 Trắc nghiệm lập trình C void main() { double k = 0; for (k = 0.0; k < 3.0; k++); printf("%lf", k); getch(); } A. 012 B. Run time error C. 3 D. 2 7. What output is? Code: #include int main() { int i = 0; for (; ; ;) printf("In for loop\n"); printf("After loop\n"); } A. Complie time error B. Infinite Loop C. Nothing 8. What output is? Code: #include #include int foo(); void main() { int i = 0; for (foo(); i == 1; i = 2) printf("In for loop\n"); printf("After loop\n"); getch(); } int foo() { return 1; } A. In for loop B. After loop C. Complie error vncoding.net Page 17 Trắc nghiệm lập trình C 9. What output is? Code: #include #include int main() { int i = 0; while (i = 0) printf("True\n"); printf("False\n"); getch(); } A. True B. False C. Complie Error D. Another 10. What output is? Code: #include #include int main() { int i = 0, j = 0; while (i < 5, j < 10) { i++; j++; } printf("%d, %d\n", i, j); getch(); } A. 5, 5 B. 10, 10 C. Syntax error 11. What output is? Code: #include #include int main() { int a = 0, i = 0, b = 0 ; for (i = 0;i < 5; i++) { a++; vncoding.net Page 18 Trắc nghiệm lập trình C continue; b++; } printf("\n a = %d,b =%d",a,b); getch(); } A. a = 5,b = 5 B. a = 4,b = 4 C. a = 5,b = 0 D. Another 12. What output is? Code: void main() { int i = 0; for (i = 0;i < 5; i++) if (i < 4) { printf("Hello"); break; } getch(); } A. Hello B. Hello is printed 3 times C. Hello is prined 4 times D. Hello is printed 5 times 13. What output is? Code: #include #include void main() { int i=0; for(;i<=2;) printf(" %d",++i); getch(); } A. 1 2 3 B. 0 1 2 3 C. 0 1 2 14. What output is? Code: vncoding.net Page 19 Trắc nghiệm lập trình C #include #include void main() { int x; for(x=1;x<=5;x++); printf("%d",x); getch(); } A. 12345 B. 123456 C. 6 D. 1234 15. What output is? Code: #include #include int main() { int i = 3; while (i--) { int i = 100; i--; printf("%d ", i); } getch(); } A. 99 99 99 B. Complier 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
- Xem thêm -

Tài liệu liên quan