Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions