Array Printing

Function Prototype

Your function must return nothing and take a single character array as a parameter. This is the array your function will print to the user using cout. Since this function does not change the passed array, you must declare it constant.

Function Definition

Remember that your numbers are stored in reverse, so you need to start from the right and work your way left. The array hould print 123456. If you’re getting 0000000000000123456, you need to add logic to your code to remove the leading zeroes.
DO NOT print a trailing end line in this function.

int array[a] = {1,2,3,4,5,6};


Second part:

You will write a function that inputs digits from the user as characters and then puts them into a character array of size ARRAY_SIZE. Since the max size may change, use the constant you declared in the homework. For testing purposes, set the constant to the value 20.



Function Prototype
Your function will return nothing and takes a character array as a parameter that will be used to store the user’s input. You CANNOT declare the array constant since you’ll be writing to it in this function.
Inputs
Your function needs to ask the user the number of digits in the number, and then inputs the actual digits in reverse. We are reversing the digits so that the 0th element of the array lines up with the ones digit, the 1st element of the array lines up with the tens digits, and so forth.
Error Condition 1: If the user types a number of digits less than or equal to 0 or a size that would exceed the size of your array, prompt the user again.
Error Condition 2: If the user types a character that is not a digit while typing the number, input the rest of the digits, and then prompt the user to enter the number again.



What the program should look like:

Enter the number of digits:
Enter XX digits in reverse:
Replace XX with the actual number of digits the user specified.
Function Definition
As the user types in each digit as a character, you’ll need to put the first digit they type into the 0th element of the array, the second digit into the 1st element, and so forth. If the user is done typing digits and they have not filled the entire array, you must put ‘0’s into the remaining array elements.
Caution: Do NOT initialize your entire array to ‘0’ and then start changing digits. This is very inefficient and there are better ways. You must implement the “better way”.



Sample Interaction
Enter the number of digits: -6
Enter the number of digits: 6
Enter 6 digits in reverse: 6*4321
Enter 6 digits in reverse: 654321
2015.2.21.3

Enter the number of digits: 6 Enter 6 digits in reverse: 654321
Topic archived. No new replies allowed.