The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Consider the following program. This program compiles and runs with no error indication, but its output is incorrect. It has an error. Which line must be changed in order for the program to produce the correct output? Â
Â
1Â Â #include <stdio.h>
2Â Â /* Find the minimum value in an array of doubles. */
3 Â Â double array_min (double x[], int length )
4Â Â {
5Â Â Â Â Â Â int i;
6Â Â Â Â Â Â double min = 0.0;
7
8Â Â Â Â Â for (i = 0; i < length; i++)
9Â Â Â Â Â {
10Â Â Â Â Â Â Â Â Â if (x[i] < min)
11Â Â Â Â Â Â Â Â Â {
12Â Â Â Â Â Â Â Â Â Â Â Â Â min = x[i];
13Â Â Â Â Â Â Â Â Â }
14Â Â Â Â Â }
15Â Â Â Â Â return min;
16Â }
17
18Â int main( void )
19Â {Â Â
20Â Â Â Â Â double n[] = {12.5, 17.2, 11.4, 8.1};
21Â Â Â Â Â double min;
22Â Â
23Â Â Â Â Â min = array_min (n, 4);
24Â Â Â Â Â printf("The minimum value is %lfn", min );
25Â Â Â Â Â return 0;
26Â }
Â
Â
| line 12 |
| line 15 |
| line 10 |
| line 23 |
| line 6 |
-----------