#include <iostream>
usingnamespace std;
int main()
{
// Ask user how many numbers he would like to store in allocated memory
cout << "How many numbers would you like to enter? : ";
// Create and initialize variables
int amount = 0, number = 0;
// Get user's amount number
cin >> amount;
// Create a pointer and point it to a new allocated memory for the amount input
int *input = new (nothrow) int[amount];
// Loops through the amount of allocated memory held and set values to them all
for (number = 0; number < amount; ++number) {
cout << "Enter number : ";
cin >> input[number];
}
// Finally prints the outcome
cout << "You entered : ";
for (number = 0; number < amount; ++number) {
number != (amount - 1) ? cout << input[number] << ", " : cout << input[number] << ".\n";
}
// Delete the allocated memory once finished with it
delete[] input;
return 0;
}
Comment what you don't find obvious. Your comments before loops are okay. Also, line 30 needs clarification. I suppose if you wrote it as an if-else statement, it would be best, but a comment wouldn't hurt either. Generally, it might be a good idea to only leave a comment before every function.