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: | 327 Weeks Ago, 4 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
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Â Â /n arr*
Find the minimum value in aay 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 |