Near the bottom I want the highest and lowest digit from an array but it doesn't reassign one of the variables in my loop. What is the problem?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int num = 10;
double numbers[num];
for(int count = 0; count < num; count++)
{
cout<<"Enter digit number " << (count + 1) << ": ";
cin>> numbers[count];
}
double highest = numbers[0];
for(int count = 1; count > num; count++)
{
if(numbers[count] > highest)
{
highest = numbers[count];
}
}
double lowest = numbers[0];
for(int count = 1; count > num; count++)
{
if(numbers[count] < lowest)
{
lowest = numbers[count];
}
}
cout<< "The higest number is: " << highest << "\n";
cout<< "The lowest number is: " << lowest << "\n";
std::cin.clear();
std::cin.sync();
std::cin.get();
return 0;
}
The both loops are organized incorrectly
Instead of
1 2 3 4 5 6 7 8 9 10
|
double highest = numbers[0];
for(int count = 1; count > num; count++)
{
....
double lowest = numbers[0];
for(int count = 1; count > num; count++)
{
|
the following condition shall be in the loops
1 2 3 4 5 6 7 8 9 10
|
double highest = numbers[0];
for(int count = 1; count < num; count++)
{
....
double lowest = numbers[0];
for(int count = 1; count < num; count++)
{
|
Last edited on
Thank you. I didn't even notice that