My output is always 0 and when I debug it my function works so it has to be the print function.
Another thing that is bugging me is that I was asked to use the function double smaller(double x, double y) but I had an issue with it. If I was using two numbers that would make sense but with 15 why?
My const say 4 at the moment because I got tired of entering in 15 numbers to see if it was working.
Code:
#include <iostream>
const int arraySize=4;
using namespace std;
void user_Prompt();
int smaller(int []);
void print_smallest();
void user_Prompt()
{
int values[arraySize];
for ( int i = 0; i < arraySize; i++ )
{
cout << "Enter value " << i << ": ";
cin >> values[i];
}
smaller(values);
}
int smaller(int values[])
{
int small;
small=values[0];
for (int i = 0; i < arraySize; i++)
{
if(values[i]<small)
{
small=values[i];
}
}
return small;
}
void print_smallest()
{
int num;
int small=smaller(&num);
cout << "The smallest number is "<< small<< endl;
}
int main ()
{
int num[arraySize];
user_Prompt();
smaller(num);
print_smallest();
return 0;
}