vietjack.com

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

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

V
VietJack
Đại họcTrắc nghiệm tổng hợp6 lượt thi
25 câu hỏi
1. Trắc nghiệm
1 điểmKhông giới hạn

What is output of following code? void main() { int ints[] = { 0, 1, 2, 3 }; int* i1 = ints + 1; int* i2 = ints + 2; int a = ++*i1 + *i2++; int b = *++i1 + *i2--; printf("%d#%d", a, b); getch(); }

4#4

4#5

5#6

4#6

Xem đáp án
2. Trắc nghiệm
1 điểmKhông giới hạn

What is output of following code? void main() { int i = 400; int *ptr = &i; *++ptr = 2; printf("%d %d", i, *ptr); getch(); }

400 2

400 400

400 401

Complier error

Xem đáp án
3. Trắc nghiệm
1 điểmKhông giới hạn

What is output? void main() { char str[] = {"pvpit"}; char *s1 = str; s1++; printf("%c", *s1); getch(); }

pvpit

vpit

v

Another

Xem đáp án
4. Trắc nghiệm
1 điểmKhông giới hạn

What is output? void main() { char *s = "\12345s\n"; printf("%d", strlen(s)); printf("\n%s", s); getch(); }

5

7

9

10

Xem đáp án
5. Trắc nghiệm
1 điểmKhông giới hạn

For the code below which lines should be reported as errors by a compiler? int main(int argc, char** argv) { const char* foo = "wow"; // line 1 foo = "top"; // line 2 foo[0] = 1; // line 3 return 0; }

1

2

3

None of the lines

Xem đáp án
6. Trắc nghiệm
1 điểmKhông giới hạn

What is output? void main() { int x = 5,y = 6; int* const p = &x; p = &y; printf("%d", (*p)); getch(); }

Complier error

6

5

Another

Xem đáp án
7. Trắc nghiệm
1 điểmKhông giới hạn

What is output? void main() { int x = 5, y = 8; const int* p; p = &x; p = &y; x++; printf("%d", *p); getch(); }

5

6

8

Complier Error

Xem đáp án
8. Trắc nghiệm
1 điểmKhông giới hạn

What is output of code? void main() { int x = 5; const int* p; p = &x; x++; *p = 4; printf("%d", *p); getch(); }

4

5

6

Complier Error

Xem đáp án
9. Trắc nghiệm
1 điểmKhông giới hạn

What is output of code? #include int main() { int a = 320; char *ptr; ptr = (char*)&a; printf("%d ", *ptr); return 0; }

320

64

Complier Error

Xem đáp án
10. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include int main() { int i = 3; int *j; int **k; j = &i; k = &j; printf("%u , %u , %d ", k, *k, **k); return 0; }

Address of j , Address of i , 3

Complier Error

3 , 3 , 3

Xem đáp án
11. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include #include int main() { char *ptr1 = NULL; char *ptr2 = 0; printf("\n%d", ptr2); strcpy(ptr1, "c"); strcpy(ptr2, "questions"); printf("\n%s %s", ptr1, ptr2); getch(); }

printf("\n%d", ptr2);

strcpy(ptr1, "c");

strcpy(ptr2, "questions");

printf("\n%s %s", ptr1, ptr2);

Xem đáp án
12. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include int main() { int a = 10; void *p = &a; int *ptr = p; printf("%u\n", *ptr); getch(); }

int a = 10;

void *p = &a;

int *ptr = p;

printf("%u\n", *ptr);

Xem đáp án
13. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include int main() { int a = 5, b = 10, c; int *p = &a, *q = &b; c = p - q; printf("%d" , c); getch(); }

3

4

5

6

Xem đáp án
14. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include int main() { int i = 5, j; int *p , *q; p = &i; q = &j; j = 5; printf("%d %d", *p, *q); getch(); }

5 5

Complier Error

5 Garbage value

Xem đáp án
15. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include void main() { int i = 5; int *p; p = &i; printf(" %u %u", *&p , &*p); getch(); }

Address of i Address of i

Garbage value Garbage value

Complier Error

Xem đáp án
16. Trắc nghiệm
1 điểmKhông giới hạn

What is output? #include #include int main() { int array[2][2][3]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; printf("%d", array[1][0][2]); getch(); }

6

7

8

9

Xem đáp án
17. Trắc nghiệm
1 điểmKhông giới hạn

What is output? #include #include void main() { char arr[8]={'V','I','E','T','N','A','M'}; char *p; p=(char *)(arr+2)[2]; printf("%c", p); getch(); }

I

E

M

N

Xem đáp án
18. Trắc nghiệm
1 điểmKhông giới hạn

What will be output of following program? #include #include void main() { char ch[]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; int *p = (int*)ch; p++; printf("%x", *p); getch(); }

37363534

34353637

45673333

Xem đáp án
19. Trắc nghiệm
1 điểmKhông giới hạn

What is output? #include #include int main() { int i = 11; int const * p = &i; p++; printf("%d", *p); getch(); }

11

12

Garbage value

Complier error

Xem đáp án
20. Trắc nghiệm
1 điểmKhông giới hạn

Which of the following statements are correct about an array? 1. The array int num[26]; can store 26 elements 2. The expression num[1] designates the very first element in the array 3. It is necessary to initialize the array at the time of declaration. 4. The declaration num[SIZE] is allowed if SIZE is a macro.

1,4

3

1,2

1

Xem đáp án
21. Trắc nghiệm
1 điểmKhông giới hạn

The library function used to find the last occurrence of a character in a string is

strnstr()

strrchr()

laststr()

strstr()

Xem đáp án
22. Trắc nghiệm
1 điểmKhông giới hạn

What is output? (assuming that the array begins at the location 1002 and size of an integer is 4 bytes) #include #include int main() { int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1)); getch(); }

1006, 2, 2

1006, 4, 4

1002, 5, 5

Error

Xem đáp án
23. Trắc nghiệm
1 điểmKhông giới hạn

What does the following declaration mean? int (*ptr)[10];

ptr is array of pointers to 10 integers

ptr is a pointer to an array of 10 integers

ptr is an array of 10 integers

ptr is an pointer to array

Xem đáp án
24. Trắc nghiệm
1 điểmKhông giới hạn

What is output? #include #include int main() { char str[] = "LAPTRINHC++\0\.NET\0"; printf("%s\n", str); getch(); }

LAPTRINHC++

LAPTRINHC++\0\.NET\0

LAPTRINHC++\0\.NET

Xem đáp án
25. Trắc nghiệm
1 điểmKhông giới hạn

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

LAPTRINHC++.NET

NETLAPTRINHC++

Address of pstr[0] Address of pstr[1]

Xem đáp án
© All rights reserved VietJack