/***********************************************************************
* Program:
* Checkpoint 01b, Arrays (e.g. Checkpoint 01b, review)
* Brother {Barney}, CS165
* Author:
* Jacob Thomas
* Summary:
* Summaries are not necessary for checkpoint assignments.
* ***********************************************************************/
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
void getSize(int&);
//void print(int);
void getList(int, int[]);//what should that be? syntax?
void displayMultiples(int, int[]);//same herE?
int getSize();
int getList();
int displayMultiples();
int main()
{
int arraySize;
int newArray[arraySize];
getSize(arraySize);
getList(arraySize, newArray);//added
displayMultiples(arraySize, newArray);//added
// print(arraySize);
return 0;
}
void getSize(int& newArraySize)
{
int arraySize;
cout << "Enter the size of the list: " ;
cin >> newArraySize;
cout << endl;
//int sizeArray[arraySize - 1 ];
}
void getList(int newArraySize, int ultraNewArray[])//added array in arguments
{
int newArray[newArraySize];//makin this -1 does not fix it
for (int x = 0 ; x <= newArraySize-1; x++)
{
int placeholder;
cout << "Enter number for index "<< x << ":" << endl;
cin >> placeholder; cout << endl;
ultraNewArray[x] = placeholder;
cout << endl;
}
}
void displayMultiples(int newArraySize, int ultraNewArray[])
{
cout << "The following are divisible by 3:\n";
for (int y = 0 ; y <= newArraySize ; y++)//adding - 1 lets the program run all the way but still causes stack overflow
{
if (ultraNewArray[y] % 3 == 0)
{
cout << ultraNewArray[y] << endl;
}
}
}
/*
void print(int newArraySize)
{
//newArraySize = arraySize;
if (newArraySize > 1)
{
cout << "Enter number for index " ;
}
}
*/