我想了解代码的输出

问题描述 投票:0回答:1

我想准确地理解此代码的输出,即输出的最后2行(输出的第4行和第5行)。

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double x = 2.1;
while (x * x <= 50) {
switch ((int) x) {
case 6:
x--;

printf("case 6, x= %f\n ", x);
case 5:
printf("case 5, x=%f\n ", x);

case 4:

printf("case 4, x=%f\n ", x);

break;
default:

printf("something else, x=%f\n ", x);
} //end switch
x +=2;

} //end while
    return 0;
}
c switch-statement
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.