CS 100 - Computational Problem Solving: Fall 2017
CS 100 - Computational Problem Solving: Fall 2017
Fall 2017
Quiz-6
Name: ___________________________________________
a. Write array function that returns the smallest-element in the array. [7]
Example 1 Example 2
5 36 12 27 2 32 29 28 35 72 31 77 68 95 72 87 74 68 85 35
2 31
min = arr[i];
return min;
}
b. What is wrong with the following loop? Explain two ways of fixing the error.
[3]
int values[10];
{
values[i] = i * i;
}
The first way to fix it is to change the “1” to a “0” and the “<=” to “<” in the
loop condition:
int values[10];
The second way to fix it is to change the “1” to “0” and the “10” to “9” in the
loop condition:
int values[10];