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

(For the following assignment, please answer in the most SIMPLEST FORM possible.

ID: 3727686 • Letter: #

Question

(For the following assignment, please answer in the most SIMPLEST FORM possible. Nothing too intricate as I am only a beginner.

Label each one my its exercise, so I know which one is which.

THANK YOU)

Exercise 7
Write a function that takes an array a of integers and its size n and returns the position (or index) of the minimum value of the array. Propose a prototype for the function. Write its code and a tester to demonstrate its use.

Continuation of Exercise 7
Redo exercise 7 using vectors.

C++ Language!

Explanation / Answer

#include<iostream>

#include<limits.h>

using namespace std;

int getMinIndex(int a[],int n)

{

int i,min=INT_MAX,minIndex=0;

for(i=0;i<n;i++){

if(a[i]<min)

{

min=a[i];

minIndex=i;

}

}

return minIndex;

}

int main()

{

int a[100],n;

cout<<"enter the size of array";

cin>>n;

cout<<"enter the elements of the array";

for(int i=0;i<n;i++)

cin>>a[i];

cout<<getMinIndex(a,n);

return 0;

}