I have a project where i'm supposed to input a list of values in an array and print them. My prints the values but it isn't the values I entered. Instead it prints out some random "20202020202020202" Is there something wrong with my code?
#include <iostream>
#include <string> //any string work include string library
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
//prototype section
void programInfo();
void inputList(double values[], int MAX_HOURS);
void printList(double values[], int n, int valuesPerLine, int count);
//void sortDescending(double values[], int n);
//double avgList(double values[], int n);
//double stdDev(double values[], int n);
//double medSortList(double values[], int n);
//void printStats(double max, double avg, double std);
int main()
{
const int MAX_VALUES = 20;
double values[20];
int n = 0;
int valuesPerLine = 0;
double max = 0;
double avg = 0;
double med = 0;
double std = 0;
int count = 0;
int values1 = MAX_VALUES;
//definitions section
void programInfo()
{
cout << "Edwin's statistical calculator." << endl;
cout << endl;
cout << "Please follow instruction carefully." << endl;
cout << "Enter a value at a time (at least 3 to up to 20)." << endl;
cout << "You must enter valid data or the program will not work." << endl;
cout << "Enter -1 to signal end of data (-1 or -1.0)." << endl;
cout << endl;
}
void inputList(double values[], int MAX_VALUES)
{
int count = 0;
Okay thanks! So I got it to output the value in the array except it's only outputting the values in the first spot of the array. How do I assign the variable n so that it becomes the values for however many spots the user enters?
void printList(double values[], int n, int valuesPerLine)
{
int count = n;
Please follow instruction carefully.
Enter a value at a time (at least 3 to up to 20).
You must enter valid data or the program will not work.
Enter -1 to signal end of data (-1 or -1.0).
Enter a value:
1
Enter a value:
2
Enter a value:
3
Enter a value:
4
Enter a value:
5
Enter a value:
-1
1 Press any key to continue . . .
It only outputs the first value I input into the array, instead of the whole array.
inputList is a module though. I get this error when I try to return count
error C2562: 'inputList': 'void' function returning a value
note: see declaration of 'inputList'