Larger than and less than in C switch statement

后端 未结 7 791
闹比i
闹比i 2020-12-29 04:57

I\'m trying to write a code that has a lot of comparison

Write a program in “QUANT.C” which “quantifies” numbers. Read an integer “x” and test it, pro

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 05:26

    (a>1000) evaluates to either 1 [true] or 0 [false].

    Compile and you will get the error:

    test_15.c:12: error: case label does not reduce to an integer constant
    

    This means, you have to use an integer constant value for the case labels. An If-else if-else loop should work just fine for this case.

提交回复
热议问题