Skip to main content
Logo image

Section 19.12 Arrays, Functions, and Pointer Arithmetic

More practice! Remember: practice makes perfect. Please pick and solve at least one of the following problems:

Subsection 19.12.1 Option 1

Activity 19.8.

Write a program that prompts the user to enter the weight of a letter and that tells the user the postage necessary to mail this letter with the US Postal Service.
Here is a sample output:
How much does your letter weigh (in ounces): 5.5
The postage is 203 cents.
Note: You can start with the code given below. Postage is calculated based on the next higher weight in the chart.
Your program should use a function, to which you pass the two relevant arrays along with their sizes, as well as the weight entered by the user, and which returns the corresponding postage. The final version of your program should use pointer arithmetic.
Does this problem look familiar? You have worked on this before, just not using functions or pointer arithmetic. Below is the code we wrote previously for this problem.

admin.....open in new window

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

Subsection 19.12.2 Option 2

Activity 19.9.

Write a C-program that finds the largest integer stored in an array of integers. You can write your code so that the array values are entered by the user (use a function for this), or you may simply hardcode an integer array for test purposes. For the main task you should definitely use a function, to which you pass the array as well as its size, and which returns the largest integer stored in the array. Your function should not access any array elements using [], but rather you should use pointer arithmetic.
Does this problem look familiar? You have worked on this before, just not using functions or pointer arithmetic. Below is the code we wrote previously for this problem.

admin.....open in new window

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

Subsection 19.12.3 Option 3

Activity 19.10.

Write a C program that finds the average of integer numbers stored in an array. You may have the user enter the array values via a function, or you can simply hard-code the array for testing purposes. For the main task you should definitely use a function to which you pass the array as well as its size, and which returns the average of the numbers stored in the array. Your function should use pointer arithmetic.
Does this problem look familiar? You have worked on this before, just not using functions or pointer arithmetic. Below is the code we wrote previously for this problem.

admin.....open in new window

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