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

Đáp án
Khi kết thúc chương trình C, giá trị nào được trả về cho hệ điều hành?
A

 

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

Đáp án
C
Bất cứ chương trình C nào đều phải có hàm main()

 

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

Đáp án
A
Dấu {} được dùng để đánh dấu điểm bắt đầu và kết thúc 1 block code (thân hàm, while, for, if/else,..)

 

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

Đáp án
B
Dấu ; được dùng để đánh dấu điểm kết thúc 1 dòng code.

 

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

Đáp án
C
Trong ngôn ngữ C, có 2 cách comment là:
"// Comments" : 1 dòng code
"/* Comment */" : 1 block code

 

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

Đáp án
B
"real" không phải là kiểu dữ liệu trong ngôn ngữ lập trình C/C++

 

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

Đáp án
D
"==" là toán tử dùng để so sánh 2 biến với nhau.

 

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

Đáp án
E
Kiểu dữ liệu boolean được định nghĩa như sau: true: giá trị khác không, false: giá trị bằng 0.

 

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

Đáp án
B
Toán tử logic AND được kí hiệu là: &&

 

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

Đáp án
A

 

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

Đáp án

 

 

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

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

A. 10
B. 9
C. 0
D. 1
Đáp án

A

 

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

Đáp án
A

 

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

Đáp án
D

 

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

Đáp án
C

 

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();

Đáp án
B
Câu lệnh khai báo hàm thiếu dấu ;

 

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

Đáp án
B

 

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();

Đáp án
C

 

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

Đáp án
B

 

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

Đáp án
A

 

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

Đáp án
B

 

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

Đáp án
C

 

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

Đáp án
D
Do không có lệnh break giữa các case. Khi x = 0, lệnh case 0 và case 2 được thực hiện.

 

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

Đáp án
D

 

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

Đáp án
C

 

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

Đáp án
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;

Đáp án
C

 

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

Đáp án
B

 

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

Đáp án
B

 

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

Đáp án
B

 

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;

Đáp án
A

 

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;};

Đáp án
D

 

33. Which properly declares a variable of struct foo?
A. struct foo;
B. struct foo var;
C. foo;
D. int foo;

Đáp án
B

 

34. Which of the following correctly declares an array?
A. int arr[10];
B. int arr;
C. arr{10};
D. array arr[10];

Đáp án
A

 

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

Đáp án
B

 

36. 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];

Đáp án
B

 

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;

Đáp án
A

 

38. 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];

Đáp án
B

 

39. Which of the following is a string literal?
A. Static String
B. “Static String”
C. ‘Static String’
D. char string[100];

Đáp án
B

 

40. What character ends all strings?
A. ‘.’
B. ‘ ‘
C. ‘\0’
D. ‘/0’

Đáp án
C

 

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

Đáp án
B

 

42. Which of the following functions compares two strings?
A. compare();
B. stringcompare();
C. cmp();
D. strcmp();

Đáp án
D

 

43. Which of the following adds one string to the end of another?
A. append();
B. stringadd();
C. strcat();
D. stradd();

Đáp án
C

 

44. In which standard library file is the function printf( ) located?
A. stdio.h
B. conio.h
C. stdlib.h
D. ouput.h

Đáp án
A

 

45. Which function is used to read the input from console?
A. scanf( )
B. printf( )
C. getch( )
Đáp án
B
46. Which of the following are NOT relational operator?
A. >
B. <
C. <=
D. None above
Đáp án
D

 

47. In the C program, the first statement that will be executed?
A. The first statement of main( )
B. The first statement of program
C. The first statement after the comment /**/
D. The first statement of end function
Đáp án
A

 

48. Why are a function phototypes useful?
A. Because they tell the complier that a function is declared later
B. Because they make program readable
C. Because they allow the programmer to see a quick list of function in the program along with the argument for each function.
D. All of the above
Đáp án
A
Function phototype chính là việc khai báo hàm. Nếu việc gọi hàm trước khi hàm được khai báo. Trình biên dịch thông báo lỗi.

 

49. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1?
A. rem = 3.14%2.1;
B. rem = fmod(3.14, 2.1);
C. rem = modf(3.14, 2.1);
D. Remainder cannot be obtain in floating point division.
Đáp án
B
Toán tử % lấy phần dư của phép chia 2 số nguyên.
Hàm fmod() lấy phần dư của phép chia 2 số thập phân.
Hàm modf() tách phần nguyên và phần thập phân.

 

50. Which of the following is not user define data type?
1.
struct book
{
    char name[10];
    float price;
    int page; };
2.
long int l = 2.3;
3.
enum day{Monday, Tuesday, Wednesday};
A. 1
B. 2
C. 3
D. 1 & 2 & 3
Đáp án
B
User define data type là kiểu dữ liệu (struct, class, enum,..) do người dùng tự định nghĩa từ các kiểu dữ liệu cơ bản

 

51. Identify which of the following are declarations
1: extern int x;
2: float func(float x) { … }
3: double pow(double, double);
A. 1
B. 2
C. 3
D. 1 and 3

Đáp án
D

 

52. Is the following statement a declaration or definition?

extern int i;
A. Declaration
B. Definition
C. A & B
Đáp án

A

 

53. Is there any difference between following declarations?

1: extern int fun( ) ;
2: int fun( );
A. Both are identical
B. No difference, except extern int fun( ); is probably in another file
C. int fun( ); is overrided with extern int fun( );
D. None of these
Đáp án
B
Khi bạn cần gọi hàm từ file .c vào file .cpp, bạn cần phải extern function

 

54. In the following program where is the variable a getting defined and where it is getting declared?

#include <stdio.h> 
void main() 
{ 
    extern int a; 
    printf("\n a = %d", a); 
} 
int a = 20; 

A. Extern int a is declaration, int a = 20 is the definition
B. Int a = 20 is declaration, extern int a is the definition
C. Int a = 20 is definition, a is not defined
D. a is declared, a is not defined

Đáp án
A

 

55. What are the types of linkages?

A. Internal and External
B. External, Internal and None
C. External and None
D. Internal
Đáp án
B

 

56. Which of the following special symbol allowed in a variable name?
A. * (asterisk)
B. | (pipeline)
C. – (hyphen)
D. _ (underscore)
Đáp án

D

 

57. By default a real number is treated as a

A. float
B. double
C. long double
D. far double
Đáp án
B

 

58. How would you round off a value from 1.66 to 2.0?

A. ceil(1.66)
B. floor(1.66)
C. roundup(1.66)
D. roundto(1.66)
Đáp án
A
Hàm ceil(x) làm tròn số thập phân thành số nguyên nhỏ nhất, lớn hơn hoặc bằng x.
Hàm floor(x) làm tròn số thập phân thành số nguyên lớn nhất, nhỏ hơn hoặc bằng x.
Hàm roundup() và roundto() không tồn tại trong thư viện ngôn ngữ C/C++

 

59. Is there any difference in the following declaration?

int func(int arr[]);
int func(int arr[20]);

A. Yes
B. No

Đáp án
A
Câu lệnh int func(int arr[]) chấp nhận đầu vào là mảng nguyên với kích thước bất kì.
Câu lệnh int func(int arr[20]) chấp nhận đầu vào là mảng nguyên với kích thước là 12.

 

60. A long double can be used if range of a double is not enough to accommodate a real number?

A. True
B. False

Đáp án

B

 

61. A float is 4 byte wide, whereas a double is 8 byte wide

A. True
B. False

Đáp án
A

 

62. Size of short integer and long integer can be verified using the sizeof( ) operator

A. True
B. False

Đáp án
A

 

63. If the definition of external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function

A. True
B. False

Đáp án
A

 

64. Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others

A. Yes
B. No

Đáp án
B

 

65. Size of short integer and long integer would vary from one platform to another

A. True
B. False

Đáp án
B

66. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

A. ABCD
B. DCBA
C. 0xABCD
D. Depend on big endian or little endian architecture.

Đáp án
D

 

67. What are the difference types of real data type in C?

A. float, double
B. short int, double, long int
C. float, double, long double
D. double, long int, float

Đáp án
C

 

68. What will be the ouput of the program?

#include <stdio.h>
#include <math.h>
#include <conio.h>

void main()
{
    float n = 1.34;
    printf("%f %f",ceil(n), floor(n));
    getch();
}

A. 1.000000  2.000000
B. 1.500000  1.000000
C. 2.000000  1.000000
D. 1.300000  2.000000

Đáp án
C
Xem thêm: hàm ceil()floor()

 

69. Which library will you add in the following program to work it correctly?

#include <stdio.h>
#include <conio.h>

void main()
{
    printf("%f", log(1.9));
    getch();
}

A. math.h
B. stdlib.h
C. log.h
D. dos.h

Đáp án
A

 

70. What will you do to treat the constant 3.14 as a long double?

A. use 3.14LD
B. use 3.14L
C. use 3.14DL
D. use 3.14LF

Đáp án
B
Hằng số 3.14 là kiểu double, 3.14L là kiểu long double
Bạn có thể test bằng câu lệnh: sizeof(3.14L) = sizeof(3.14) = 8 (byte) (Visual C++ 2008 x86)

 

71. What will you do to treat the constant 3.14 as a float?

A. use float(3.14f)
B. use 3.14f
C. use f(3.14)
D. use (f)(3.14)

Đáp án
B
Bạn có thể test bằng câu lệnh: sizeof(3.14f) = 4 (byte) (Visual C++ 2008 x86)

 

72. We want to round off x, a float, to an int value, The correct way to do is:

A. y = (int)(x + 0.5)
B. y = int(x + 0.5)
C. y = (int)x + 0.5
D. y = (int)((int)x + 0.5)

Đáp án
A
Round off ở đây có nghĩa là làm tròn số thập phân.
Ví dụ: 3.45 –> 3, 3.5 –> 4.
Do vậy, ở đây để làm tròn x ta cộng thêm 0.5.
Đáp án B cũng có thể đúng, nhưng đáp án A là chuẩn nhất, đảm bảo đúng trên mọi compiler.

 

73. What will be output of the program?

#include <stdio.h>
#include <conio.h>

void main()
{
    float n = 1.67;
    printf("%e, ", n);
    printf("%f, ", n);
    printf("%g, ", n);
    printf("%lf, ", n);
    
    getch();
}

A. 1.670000e+000, 1.670000, 1.67, 1.670000,
B. Complier Error
C. 1.67e, 1.67000, 1.670, 1.67
D. 1.67e, 1.67, 1.67000, 1.67f

Đáp án
A
%e: in ra kiểu số mũ.
%f: in ra kiểu dấu phẩy động
%g: in ra dạng rút gọn của %f hoặc %e
%lf: in ra kiểu dấu phẩy động.

 

74. What will be output of program?

#include <stdio.h>
#include <conio.h>

void main()
{
    float n = 0.7;
    if(n < 0.7f)
        printf("vncoding");
    else
        printf("abc");

    getch();
}

A. vncoding
B. abc
C. Complier error
D. None of these

Đáp án
B
0.7f là hằng số kiểu float. Biểu thức so sánh 0.7 < 0.7f trả về false.

 

75. What will be output of program?

#include <stdio.h>
#include <conio.h>

void main()
{
    float n = 0.7;
    if(n < 0.7)
        printf("vncoding");
    else
        printf("abc");

    getch();
}

A. vncoding
B. abc
C. Complier error
D. None of these

Đáp án
A

 

76. If the file tobe included does not exist, the preprocessor flashes an error message
A. True
B. False

Đáp án
A
Complier sẽ thông báo lỗi nếu thiếu file #include

 

77. What is output of the program?

#include <stdio.h>
#include <conio.h>

void main()
{
    int y = 100;
    const int x = y;
    printf("%d", x);

    getch();
}

A. 100
B. Garbage value
C. Error
D. 0

Đáp án
A
hằng số x được khởi tạo bằng 100.

 

78. What will happen if in the C program you assign a value to a array element whose subscript exceeds the size of array?
A. The element will be set to 0.
B. The complier would report an error.
C. The program may crash if some important data gets overwritten
D. The array size would appropriately grow

Đáp án
C
Khi bạn assign giá trị cho phần tử vượt quá kích thước của mảng. Xảy ra problem là buffer overrun. Có nghĩa là sử dụng vùng nhớ ko hợp lệ (ví dụ: đang lưu giá trị của một biến khác,…), làm cho chương trình bị crash.

 

79. What is output of the program?

#include <stdio.h>
#include <math.h>
#include <conio.h>

void main()
{
    printf("%f", sqrt(36.0));
    getch();
}

A. 6.000000
B. 6
C. Error

Đáp án
A
Xem thêm hàm sqrt()

 

80. In which stage the following code

#include <stdio.h>

Gets replaced by the contents of the file stdio.h
A. During editing
B. During linking
C. During execution
D. During preprocessing

Đáp án
D

 

81. What will be output of the program?

#include <stdio.h>
#include <conio.h>

void main()
{
    printf("%d  %d  %d", sizeof(3.14), sizeof(3.14f), sizeof(3.14l));
    getch();
}

A. 8 4 8
B. 4 4 8
C. 4 8 10
D. 4 8 12

Đáp án
A
3.14 là hằng số kiểu double
3.14f là hằng số kiểu float
3.14l là hằng số kiểu long double

 

82. A function cannot be defined inside another function
A. True
B. False

Đáp án
A
Không thể define 1 hàm trong 1 hàm khác, ta chỉ có thể gọi hàm trong 1 hàm khác.

 

83. What is the notation for following functions?

1. 
int func(int a, int b)
{
    /*Some code*/
}
2. 
int func(a, b)
int a; int b;
{
    /*Some code*/
}

A. 1. KR Notation and 2. ANSI Notation
B. 1. Pre ANSI C Notation and 2. KR Notation
C. 1. ANSI Notation and 2. KR Notation
D. 1. ANSI Notation and 2. Pre ANSI Notation

Đáp án
C

 

84. Name of functions in two different files linked together must be unique.
A. True
B. False

Đáp án
A

 

85. If return type for a function is not specified, it defaults to int
A. True
B. False

Đáp án
A

 

86. A function may have ant number of return statements each returning different values.
A. True
B. False

Đáp án
A
Một hàm có thể sử dụng nhiều cầu lệnh return với các giá trị trả về khác nhau

 

87. Functions cannot return more than one value at a time
A. True
B. False

Đáp án
A

 

88. Function can be called either by value or reference
A. True
B. False

Đáp án
A
Hàm gọi theo cách tham trị và tham chiếu

 

89. How many times the program will print “vncoding”?

#include<stdio.h>

void main()
{
    printf("vncoding");
    main();
}

A. Infinite times
B. 65535 times
C. Till stack overflows
D. Cannot call main( ) in main( )

Đáp án
C

 

90. In C all function except main( ) can be called recursively
A. True
B. False

Đáp án
B
Tất cả các hàm bao gồm cả hàm main đều có thể đệ quy.

 

91. Is it true that too many recursive calls may result into stack overflow?
A. Yes
B. No

Đáp án
A
Vì khi hàm được gọi, địa chỉ hàm + giá trị trả về của hàm +… được lưu stack.

 

92. Maximum number of arguments that a function can take is 12
A. Yes
B. No

Đáp án
B
Không rõ là bao nhiêu :). Nhờ các bạn check giúp.

 

93. Usually recursion works slower than loops
A. Yes
B. No

Đáp án
A

 

94. In a function two return statements should never occur.
A. Yes
B. No

Đáp án
B
Trong ngôn ngữ C, có thể sử dụng nhiều câu lệnh return trong 1 hàm. Ngoại trừ, viết 2 câu lệnh return liên tiếp nhau.

 

95. There is a error in the below program. Which statement will you add to remove it

#include<stdio.h>

void main()
{
    int a;
    a = f(1, 3.14);
}

float f(int a, float b)
{
    return ((float)a + b);
}

A. Add prototype: float f(int, float);
B. Add prototype: float f(a, b);
C. Add prototype: float f(float a, int b)

Đáp án
A

 

96. Every function must return a value
A. Yes
B. No

Đáp án
B
Hàm có kiểu trả về là void thì trong thân hàm không cần gọi lệnh return.

 

97. Which of the following statements are correct about the program?

#include <stdio.h>
#include <conio.h>

void main()
{
    printf("%p", main());
    getch();
}

A. It prints garbage values infinitely
B. Runs infinitely without printing anything
C. Error: main( ) cannot be called inside printf( )
D. No Error and print nothing

Đáp án
B

 

98. Will the following functions work?

int f1(int a, int b)
{
    return(f2(20));
}

int f2(int a)
{
    return a*a;
}

A. Yes
B. No

Đáp án
B
Vì hàm f2 được gọi trước khi được define. Nên khai báo hàm f2()

 

99. If a function contains two return statements successively, the complier will generate warnings. Yes / No?
A. Yes
B. No

Đáp án
B
Vì gặp lệnh return thứ nhất, kết thúc hàm.
Nếu 1 hàm dùng nhiều câu lệnh return liên tiếp nhau, chỉ có câu lệnh return đầu tiên có ý nghĩa, các câu lệnh sau nó ko bao giờ được thực hiện.

 

100. Functions can not return a floating point number
A. Yes
B. No

Đáp án
B

 

101. What will be the output of the program?

#include <stdio.h>
#include <conio.h>

int reverse(int);

void main()
{
    int n = 5;
    reverse(n);
    getch();
}

int reverse(int n)
{
    if(n == 0)
        return 0;
    else
        printf("%d", n);
    reverse(n--);
}

A. 543210
B. 54321
C. 12345
D. Infinite loop

Đáp án
D
Hàm reverse() là hàm đệ quy.
n = 5, câu lệnh gọi hàm reverse(n–) <=> reverse(5) vì biến n giảm sau khi gọi hàm.
Vì giá trị truyền vào cho hàm reverse ko thay đổi. Do vậy, chương trình đệ qui rơi vào vòng lặp vô hạn.
Để fix chương trình này, thay reverse(n–) bằng reverse(–n).

 

102. What will be the output of the program?

#include <stdio.h>
#include <conio.h>

void main()
{
    int func(int);
    int i = func(5);
    printf("%d", --i);
    getch();
}

int func(int n)
{
    return(n++);
}

A. 4
B. 5
C. 6
D. Another

Đáp án
A
Ngôn ngữ C, cho phép bạn khai báo hàm trong 1 hàm khác.
Hàm func(5) trả về là 5 không phải là 6, vì giá trị n được tăng sau khi thực hiện xong câu lệnh return.

 

103. Point out a error of the following program

f(int a, int b)
{
    int a;
    a = 20;
    return a;
}

A. Missing parenthesis in return statement
B. The function should be defined as int f(int a, int b)
C. Re-declaration of a
D. None of above

Đáp án
B
Hàm được định nghĩa chưa có kiểu trả về. Một số chương trình biên dịch sẽ không chấp nhận điều này.

 

104. Point out the error in the program

#include <stdio.h>
#include <conio.h>

int f(int a)
{
    a > 20 ? return(1) : return(0);
}

void main()
{
    int f(int);
    int b = f(20);
    printf("%d", b);
    getch();
}

A. Error: Prototype declaration
B. No error
C. Error: return statement cannot be used with conditional operators
D. None of above

Đáp án
C
Sau toán tử điều kiện (? :) phải là biểu thức toán học, không thể là câu lệnh (return).
Câu lệnh “a > 20 ? return(1) : return(0);” nên đổi thành “return (a > 20 ? 1 : 0);”

 

105. What will be the output of the program?

#include<stdio.h>
#include <conio.h>

int func(int i, int j)
{
    int k, l;
    k = i + j;
    l = i * j;
    return (k, l);
}

void main()
{
    int i = 2, j = 3, k, l;
    k = func(i, j);
    l = func(i, j);
    printf("%d  %d", k, l);
    getch();
}

A. 6 6
B. 5 6
C. Complier error
D. None of above

Đáp án
A
k = i + j = 5
l = i*j = 6
Câu lệnh return(k, l) = return(5, 6) = return(6).

 

106. What will be output of the program?

#include<stdio.h>
#include <conio.h>

int f1(int);
int f2(int);

void main()
{
    extern int i;
    int j = 3;
    f1(j);
    printf("%d,", j);
    f2(j);
    printf("%d", j);
    getch();
}

int f1(int i)
{
    printf("%d,",++i);
    return 0;
}
int f2(int j)
{
    printf("%d,", ++j);
    return 0;
}

A. 4, 3, 4, 3
B. 4, 4, 5, 5
C. 3, 4, 3, 4
D. None of above

Đáp án
A

 

107. Which of the following statements are correct about this function

long fun(int n)
{
    int i;
    long f = 1;
    for(i = 1; i <= n; i++)
        f = f*i;
    return f;
}

A. The function calculates the value of 1 raised to power n
B. The function calculates the factorial value of an integer
C. The function calculates the square root of an integer
D. None of above

Đáp án
B
Hàm fun() tính giai thừa của n.

 

108. Point out the error in the following program

#include <stdio.h>
#include <conio.h>

void main()
{
    int a = 10;
    void f();
    a = f();
    printf("%d", a);
    getch();
}

void f()
{
    printf("vncoding");
}

A. Error: cannot convert ‘void’ to ‘int’
B. Error:

Đáp án
A

5 Comments on Khái niệm cơ bản ngôn ngữ lập trình C

Leave a Reply to TienLuongJS Cancel reply