I have an excercise to do for college and one of the questions is as follows
a. Write a prototype for a function LargestInputValue that will allow the user to
enter a list of positive integers, followed by a terminator value –1. The
function should return the largest value entered.
b. Write a definition for the function LargestInputValue
c. Write a test application that will use the function LargestInputValue
The problem I'm having is how do I allow the user to enter there own numbers using cin, I know it involves a for loop.
lets say I declared an array in main int Array[20];
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include iostream;
using namespace std;
int main()
{
for (int i = 0; i < 20; i++)
{
cin >> First[i];
}
cout << First;
}
| |
But when I try output my array, It gives me the a hexdecimal memory address. How would I go about outputing All the elements in the array on the screen that the user just populated? Also can you explain Why the memory address is showing up, I know its completley wrong and the cout << First makes no sense but Im just giving you an idea what I'am trying to achieve.