Question: There are two errors in the following code, please indicate what line number they are on and how to fix it. It may be functional
There are two errors in the following code, please indicate what line number they are on and how to fix it. It may be functional or syntactical. The following code finds the two highest values (saves highest in max1 and second highest in max2) in an array called testArray.
1. int testArray[100]; 2. int index = 0; 3. int max1 = 0; 4. int max2 = 0; 5. for(index = 0; index <= 100; ++index) 6. { 7. if(testArray[index] > max1) 8. { 9. max1 = testArray[index]; 10. max2 = max1; 11. } 12. else if (testArray[index] > max2); 13. { 14. max2 = testArray[index]; 15. } 16. }
Please use C language for this problem
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
