C++ - Determining the largest number out of 15 numbers entered

Good Afternoon,

This is my first attempt at writing a C++ program. I recently learned programming in C and it did not seem to be a problem for me. I am feeling pretty stupid with this program. Here is the question:

Create a program to determine the largest number out of 15 numbers entered (numbers entered one at a time). This should be done in a function using this prototype:

double larger (double x, double y);

Make sure you use a for loop expression inside your function.

Enter 15 numbers

11 67 99 2 2 6 8 9 25 67 7 55 27 1 1

The largest number is 99

Hints:

* Read the first number of the data set. Because this is the only number read to this point, you may assume that it is the largest number so far and call it max.

* Read the second number and call it num. Now compare max and num, and store the larger number into max. Now max contains the larger of the first two numbers.

* Read the third number. Compare it with max and store the larger number into max.

* At this point, max contains the largest of the first three numbers. Read the next number, compare it with max, and store the larger into max.

Repeat this process for each remaining number in the data set using a for expression.

Here is my code:

Code:

`#include <iostream>`

using std::cout;

using std::cin;

using std::endl;

int main()

{

int max;

int num;

for (int counter = 0; counter<15; counter++)

{

cout <<"Enter a number: ";

cin >> max;

cout << "Enter another number: ";

cin >> num;

if (num > max)

num = max;

cout << "The largest number is " <<max;

}

return 0;

}

As you can see, I have the largest number line printing out after every user input number. I know it's probably something wrong with my for loop or my braces, but I can not figure it out for the life of me. Any input will be appreciated. Thank you.