Write a program to determine and display the smallest and largest valuescontained in 99-elcment floating-point array w.
时间: 2024-02-25 10:55:55 浏览: 28
Sure, here's a program in C to determine and display the smallest and largest values contained in a 99-element floating-point array `w`:
```c
#include <stdio.h>
int main() {
float w[99]; // declare the array
float smallest, largest; // variables to store the smallest and largest values
// code to fill the array with values goes here
// initialize smallest and largest to the first element of the array
smallest = w[0];
largest = w[0];
// loop through the array and update smallest and largest as necessary
for (int i = 1; i < 99; i++) {
if (w[i] < smallest) {
smallest = w[i];
}
if (w[i] > largest) {
largest = w[i];
}
}
// display the smallest and largest values
printf("Smallest value: %f\n", smallest);
printf("Largest value: %f\n", largest);
return 0;
}
```
Note that you'll need to add code to fill the array `w` with values before the loop that determines the smallest and largest values.