What does the code section below will display? ……… void funct(void); ……… float x=2,y=3,z=4; int main () { int x, y; x = 20; y = 30; ….. funct(); z = x + y; printf ("value of x = %d, y = %d and z = %5f\n", x, y, z); …… return 0; } void funct() { int x = 32767; int z=x+y; printf("value of x = %d, y = %d and z = %5f\n", x, y, z); }
时间: 2023-12-03 20:02:00 浏览: 217
The code section will display the following output:
```
value of x = 20, y = 30 and z = 32797.000000
```
Here's how the program works:
- In the `main` function, the variables `x`, `y`, and `z` are declared and initialized with the values 2, 3, and 4 respectively.
- The variables `x` and `y` are then re-declared and initialized with the values 20 and 30 respectively.
- The function `funct` is called, which declares a local variable `x` and initializes it with the value 32767. It then declares a variable `z` and initializes it with the value of `x + y`, which is 32797.
- The `printf` statement in `funct` displays the values of `x`, `y`, and `z`, which are 32767, 30, and 32797 respectively.
- After `funct` returns, the value of `z` in `main` is updated to the value of `x + y`, which is 50.
- The `printf` statement in `main` displays the values of `x`, `y`, and `z`, which are 20, 30, and 50 respectively. Note that the value of `z` is not affected by the `funct` function since the `z` variable in `funct` is local to that function.
阅读全文