Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I am studying for a test and this is the practice debugging section I got

ID: 3721453 • Letter: H

Question

Hello

I am studying for a test and this is the practice debugging section I got and I am going through trying to find the errors and then write down what to enter that would correct it. I have found a few of them but there are some that I still can't find. I was told that there should be 10 mistakes. I have ran it through my Visual Studio but the mistakes I am having problems making the corrections also.

I have to take my test May 3rd. Please help for my review.

#include <iostream>;

use namespace std

int min(const int a[], int size)

int main()

{

       int[] a = { 3,2,1,6,5,7 };

       cout >> "The minimum value in array a is: " >> min(a);

       System("pause");

       return 0;

}

int min(int a[], int size);

{

       int result = a(0);

       for (Int index == 1; index < size; index++)

       {

              if (result > a[index])

                     result = a[index];

      

}

Explanation / Answer

hi dear as per you requiremnt i have highlighted the errors and written the corresponding correct statements. Please check the below code. TRy to run the program in and IDE you will now get the correct output.

==============================================================

Program:

==============================================================

//Error 1 semicolon is not required

//#include <iostream>;

//Correct

#include<iostream>

//Error 2 wrong namespace

//use namespace std

using namespace std;

//Error 3 semicolon missing in function prototype

//int min(const int a[], int size)

int min(const int a[], int size);

int main()

{

       //Error 4 wrong array declration

       //int[] a = { 3,2,1,6,5,7 };

       int a[] = {3, 2, 1, 6, 5, 7};

       //Error 5 you have not find the size of the array

       int size = sizeof(a)/sizeof(int);

       //Error 6 wrong function calling

       //cout >> "The minimum value in array a is: " >> min(a);

       //Correct

       cout<<"The minimum value in array a is: "<<min(a, size)<<endl;

       System("pause");

       return 0;

}

//error 7 no semicolon required in function defintion

//int min(int a[], int size);

//correct

int min(const int a[], int size)

{

//Error 8 wrong value assign

//int result = a(0);

//correct

int result = a[0];

//error 9 data type is wrong

//for (Int index == 1; index < size; index++)

//correct

for(int index = 1; index < size; index++)

{

if (result > a[index])

result = a[index];

}

//error 10 missing closing braces and return value

//corret

return result;
}


===============================================================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote