answersLogoWhite

0

#include

using std::cin;
using std::cout;
using std::endl;

void setData(double data[], const int& dataSize);
void min(const double data[], const int& dataSize);
void max(const double data[], const int& dataSize);

int main()
{
const int numberOfElements = 6;
double myArray[numberOfElements] = {0.0};

cout << endl << "Enter " << numberOfElements << " elements of your array" << endl;
setData(myArray, numberOfElements);

min(myArray, numberOfElements);
max(myArray, numberOfElements);

cout << endl;
system("PAUSE");
return 0;

}

void setData(double data[], const int& dataSize)
{
for (int i(0); i < dataSize; i++)
{
cout << (i + 1) << " element: ";
cin >> data[i];
}
}
void min(const double data[], const int& dataSize)
{
int minValPos(0);
double minVal = data[0];
for (int i(0); i < dataSize; i++)
{
if (minVal > data[i])
{
minVal = data[i];
minValPos = i;
}
}

cout << endl << "Minimum value is: " << minVal
<< " its position is: " << minValPos << endl;

return;
}
void max(const double data[], const int& dataSize)
{
int maxValPos(0);
double maxVal = data[0];
for (int i(0); i < dataSize; i++)
{
if (maxVal < data[i])
{
maxVal = data[i];
maxValPos = i;
}
}

cout << endl << "Maximum value is: " << maxVal
<< " its position is: " << maxValPos << endl;

return;
}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How the program statement and code are related?

A statement in your program is part of the code. In a low-level programming language, a statement will map directly to a single CPU instruction. In a high-level programming language, a statement is the smallest element of the language's syntax.


Simple c program for selection sort?

The Selection Sort definition is rather simple : find the largest number (element) in a list and move it to it's position in sorted form.You can perform selection sort like, smallest elements are in the beginning and largest element at the end.Now how this element arrange to it's exact position,We can do this by swapping elements at highest index and the process is continue till all the elements are sorted.


What is the smallest amount in an element?

The smallest quantity of an element is an atom.


What the smallest particle of an element that can be identified as that element is?

a quark or if you mean the smallest element hydrogen


What is the valency of the smallest element?

the smallest element is hydrogen of which its valency is one.


What is the smallest element?

ATOM


The smallest unit of an element that has all of the properties of the element is an?

The atom is the smallest unit of an element that has all the properties of the element.


What smallest unit of an element is?

The smallest identifiable unit of an element that retains the properties of the element is an atom.


The smallest particle of an element is called?

The smallest particle of an element is called an atom.


The primary unit of data in the Future Years Defense Program (FYDP) and normally the smallest aggregation of resources controlled by the office of the Secretary of Defense (OSD) is the?

Program Element


Smallest part of an element?

An atom is the smallest particle that is still recognisably the element


What is the smallest part of a element that occurs naturally?

atom is the smallest part of element