Tạo Trắc Nghiệm

700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 15

25 câu · Đề ôn tập tổng hợp

Xem trước: đọc nhanh mọi câu dạng chữ, chưa tính giờ, chưa hiện đáp án.
Luyện tập: chọn đáp án là biết đúng sai ngay, kèm lời giải.
Thi thử: nộp bài mới chấm điểm và hiện lời giải.

Câu 1

What is output? #include #include void swap(char **, char **); int main() { char *pstr[2] = {"LAPTRINHC++", ".NET"}; swap(&pstr[0], &pstr[1]); printf("%s%s", pstr[0], pstr[1]); getch(); } void swap(char **t1, char **t2) { char *t; t=*t1; *t1=*t2; *t2=t; }

Đáp án và lời giải

Đáp án: B

Câu 2

What is output? Giả sử dùng VC++ 2008 trên hệ điều hành 32 bit #include #include typedef struct { char c; // 1 byte float b; // 4 byte int a; // 4 byte }A; void main() { printf("\n Size of struct: %d", sizeof(A)); getch(); }

Đáp án và lời giải

Đáp án: B

Câu 3

What is output? #include #include typedef struct { int a[2]; // 8 byte char b[5]; // 5 byte char c[5]; // 5 byte }A; void main() { printf("\n Size of struct: %d",sizeof(A)); getch(); }

Đáp án và lời giải

Đáp án: A

Câu 4

What is output? #include #include struct birthday { int d; // day int m; // month int y; // year }; struct info { int ID; // code of staff birthday b; }; void main() { info a = {1009, 16, 9, 1989}; printf("\nID=%d, dd/mm/yyyy = %d/%d/%d",a.ID,a.b.d,a.b.m,a.b.y); getch(); }

Đáp án và lời giải

Đáp án: A

Câu 5

What is output? #include #include void main() { struct site { char name[] = "laptrinhc++"; int year = 2; }; struct site *ptr; printf("%s ", ptr->name); printf("%d", ptr->year); getch(); }

Đáp án và lời giải

Đáp án: B

Câu 6

What is output? #include #include typedef struct { int x; static int y; }st; void main() { printf("sizeof(st) = %d", sizeof(st)); getch(); }

Đáp án và lời giải

Đáp án: A

Câu 7

What is output? #include #include struct { short s[5]; union { float y; long z; }u; } t; void main() { printf("sizeof(st) = %d", sizeof(t)); getch(); }

Đáp án và lời giải

Đáp án: A

Câu 8

Which of the following operators can be applied on structure variables?

Đáp án và lời giải

Đáp án: D

Câu 9

What is output? #include #include #define x 5+2 void main() { int i; i = x*x*x; printf("%d", i); getch(); }

Đáp án và lời giải

Đáp án: B

Câu 10

What is output? #include #include #define call(x,y) x##y void main() { int x = 5, y = 10, xy = 20; printf("%d", xy + call(x, y)); getch(); }

Đáp án và lời giải

Đáp án: C

Câu 11

What is output? #include #include #if X == 3 #define Y 3 #else #define Y 5 #endif void main() { printf("Y = %d", Y); getch(); }

Đáp án và lời giải

Đáp án: B

Câu 12

What is output? #include #include #define X 3 #if !X printf("C/C++"); #else printf("Java"); #endif void main() { getch(); }

Đáp án và lời giải

Đáp án: C

Câu 13

What is output? #include #include #define ISEQUAL(X, Y) X == Y void main() { #if ISEQUAL(X, 0) printf("C/C++"); #else printf("Java"); #endif getch(); }

Đáp án và lời giải

Đáp án: C

Câu 14

What is output? #include #include #define SQUARE(x) x*x void main() { int x; x = 36 / SQUARE(6); printf("%d", x); getch(); }

Đáp án và lời giải

Đáp án: B

Câu 15

What is output? #include #include #define a 10 void main() { printf("%d ", a); #define a 50 printf("%d ", a); getch(); }

Đáp án và lời giải

Đáp án: A

Câu 16

What is output? #include #include #define MAX 1000 void main() { int MAX = 100; printf("%d ", MAX); getch(); }

Đáp án và lời giải

Đáp án: C

Câu 17

What is output? #include #include #define PRINT(i, limit) do \ { \ if (i++ < limit) \ { \ printf("laptrinhc++"); \ continue; \ } \ }while(1) void main() { PRINT(0, 3); getch(); }

>

Đáp án và lời giải

Đáp án: C

Câu 18

A ____ is a special member function used to initialize the data members of a class.

Đáp án và lời giải

Đáp án: A

Câu 19

The default access for members of a class is ___ .

Đáp án và lời giải

Đáp án: A

Câu 20

Member functions of a class are normally made ___ and data members of a class are normally made ___ .

Đáp án và lời giải

Đáp án: C

Câu 21

Inheritance enables ___ which saves time in development , and encourages using previously proven and high quality software.

Đáp án và lời giải

Đáp án: A

Câu 22

The three member access specifiers are ___, ___ and ___ .

Đáp án và lời giải

Đáp án: A

Câu 23

A “has a” relationship between classes represents ___ and an “is a” relationship between classes represent ___ .

Đáp án và lời giải

Đáp án: A

Câu 24

A pure virtual function is specified by placing ___ at the end of its prototype in the class definition.

Đáp án và lời giải

Đáp án: A

Câu 25

A operator ___ is called as de-referencing operator.

Đáp án và lời giải

Đáp án: B