# Poll: Kiểm tra kiến thức C - 2.3

**URL:** https://daynhauhoc.com/t/poll-kiem-tra-kien-thuc-c-2-3/998
**Category:** programming
**Tags:** c
**Created:** [October 29, 2014, 8:56am UTC](https://daynhauhoc.com/t/poll-kiem-tra-kien-thuc-c-2-3/998 "2014-10-29T08:56:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![qtd](https://daynhauhoc.com/user_avatar/daynhauhoc.com/qtd/32/2920_2.png) [@qtd](https://daynhauhoc.com/u/qtd)
#### Post date: [October 29, 2014, 8:56am UTC](https://daynhauhoc.com/t/poll-kiem-tra-kien-thuc-c-2-3/998/1 "2014-10-29T08:56:42Z")

</div>

Các bạn thảo luận đáp án nhé, bài test lấy từ [http://www.indiabix.com/online-test/c-programming-test/12](http://www.indiabix.com/online-test/c-programming-test/12)  
3.Point out the error, if any in the program.

```auto
#include<stdio.h>
int main()
{
    int P = 10;
    switch(P)
    {
       case 10:
       printf("Case 1");

       case 20:
       printf("Case 2");
       break;

       case P:
       printf("Case 2");
       break;
    }
    return 0;
}

```

- A. Error: No default value is specified
- B. Error: Constant expression required at line case P:
- C. Error: There is no break statement in each case.
- D. No error will be reported.

---

<div class="post-metadata">

### Author: ![ltd](https://daynhauhoc.com/user_avatar/daynhauhoc.com/ltd/32/37284_2.png) [@ltd](https://daynhauhoc.com/u/ltd)
#### Post date: [October 29, 2014, 9:38am UTC](https://daynhauhoc.com/t/poll-kiem-tra-kien-thuc-c-2-3/998/2 "2014-10-29T09:38:36Z")

</div>

B. Case P không phù hợp, vì P không phải là hằng. Switch yêu cầu case của nó phải là hằng số mới được.

---

<div class="post-metadata">

### Author: ![qtd](https://daynhauhoc.com/user_avatar/daynhauhoc.com/qtd/32/2920_2.png) [@qtd](https://daynhauhoc.com/u/qtd)
#### Post date: [October 29, 2014, 9:43am UTC](https://daynhauhoc.com/t/poll-kiem-tra-kien-thuc-c-2-3/998/3 "2014-10-29T09:43:58Z")

</div>

Lần sau anh chỉ trả lời thôi. Đừng đưa đáp án của mình ra.Trả lời tiếng anh. Cho mấy bạn khác còn quan tâm. Em thấy nhiều người đi vào rồi lại đi ra.  
Ví dụ. Switch require case expression must be constant value. Như thế người khác mới có hứng tìm hiểu vì sao chứ =\_\_\_=
