Larger than and less than in C switch statement

后端 未结 7 855
闹比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:18

    use type parameter pattern along with when clause e.g.

    switch(a)
        {
            case * when (a>1000):
                printf("hugely positive");
                break;
            case * when (a>=100 && a<999):
                printf("very positive");
                break;
            case * when (a>=0 && a<100):
                printf("positive");
                break; }
    

提交回复
热议问题