Computer Organization Lab #4: Reverse Array (C)

  1. In C you can print the value of a pointer using the %p format specifier in printf. Now consider the following declaration of an initialized array of integers:

            int array[8] = { 100, 110, 120, 130, 140, 150, 160, 170 };
          

    Write a C program that prints the value of the following expressions. Try to predict what each one will print before you run your program. You won't know the starting address of the array, but you should be able to predict the results in terms of that unknown address.

  2. Write a function with the declaration:

              void reverse_array(int *first, int *last);
            

    The function should reverse the order of the elements in the array. The parameter first points at the first element and the parameter last points just past the last element. Write a main function that demonstrates reverse_array.

Submit your final program to moodle. You don't have to submit any results for the first part (the intention of the first part is to give you insights to make writing the program easier.


Last Revised: 2017-03-08
© Copyright 2017 by Peter C. Chapin <PChapin@vtc.vsc.edu>