1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Iteru [2.4K]
4 years ago
9

Write a complete function called lowestPosition() which takes as array (of double) and the number of elements used in the array

(as an int) and returns the position of the element with the least value (as an int). You may assume the number of elements is >
Computers and Technology
1 answer:
stiv31 [10]4 years ago
3 0

Answer:

#include <bits/stdc++.h>

using namespace std;

int lowestPosition(double elements[],int n)//function to find position of lowest value element.

{

   int i,pos;

   double min=INT_MAX;

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

   {

       if(elements[i]<min)

       {

           min=elements[i];

           pos=i;//storing index.

       }

   }

   return pos+1;//returning pos +1 to give the correct position in the array.

}

int main() {

double ele[500];

int n;

cout<<"Enter number of values"<<endl;

cin>>n;

cout<<"Enter elements"<<endl;

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

{

   cin>>ele[i];

}

int pos=lowestPosition(ele,n);//function call.

cout<<"The position of element with minimum value is "<<pos<<endl;

return 0;

}

Output:-

Enter number of values

5

Enter elements

4 6 7 5 1

The position of element with minimum value is 5

Explanation:

I have created a function lowestPosition() with arguments double array and it's size.I have taken a integer variable pos to store the index and after finding minimum and index i am returning pos+1 just to return correct position in the array.

You might be interested in
If you were looking for a record in a very large database and you knew the ID number, which of the following would be the most d
dezoksy [38]

Answer:

By the record ID

Explanation:

5 0
4 years ago
In C++ Please:
diamong [38]

Answer:

result = sqrt(number);

Explanation:

#include <math.h>  is the header file for this function.

6 0
4 years ago
Chances are if you ar Chances are, if you are involved in a crash, it will happen __________ a. during a long trip. b. close to
JulijaS [17]
During a long trip. Hope this helps!
6 0
3 years ago
Read 2 more answers
Write a 10 sentence paragraph about george washington and abraham lincoln and no plagiarism
Mamont248 [21]
10 sentence paragraph about George Washington and Abraham Lincoln and no playgiarism
8 0
3 years ago
Read 2 more answers
"where is a cookie that is created during a web site visit​ stored?"
tino4ka555 [31]
On the visitor's computer
5 0
3 years ago
Other questions:
  • 9.6 Code Practice: Question 1
    9·1 answer
  • A window frame will expand to fill the entire desktop when you
    15·1 answer
  • ______ is the software that prevents people from being able to access your personal information.
    8·2 answers
  • What is a statement that adds 1 to the int j when the int counter has a value less than the int n?
    12·1 answer
  • Consider the classes below: public class TestA { public static void main(String[] args) { int x = 2; int y = 20 int counter = 0;
    8·1 answer
  • What is the general form of an internet email address<br>​
    5·1 answer
  • 4.3 Code Practice<br> edhisve
    13·1 answer
  • Dividing a hard drive into multiple sections is known as partitioning
    5·1 answer
  • Typically, a DVD has how many times more capacity than a CD?
    12·1 answer
  • Difference between customized and packaged software​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!