Skip to main content
Logo image

Section 27.8 Function to Print a Number

So far we have only printed a 3-digit number by dereferencing successively the pointers to the three digits. This is not something that could be generalized to an arbitrarily long number and that’s why next our goal is to print an arbitrary number using a function to which we only pass a pointer to the first digit of the number.

Activity 27.5.

Let’s move the printing of our number into a function. The function should work for arbitrarily long numbers, not just for our 3-digit number. Please write a function printNumber() to which you pass a pointer to the first digit of your number and which prints all of the digits of the number to the screen. The function does not need to return anything.

admin.....open in new window

When you are done, please paste your code into the code submission box below: