Assignment: #carcdr Due: 11/04/2017 Points: 5

Specification

Write a C++ program that implements two functions named car and cdr.

int car(int* list)

The car() function receives an a pointer to array of int values and returns the value of element zero of the array.

int* cdr(int* list)

The cdr() function receives an a pointer to array of int values and returns a pointer to the array that excludes element zero.

int main(int, char**)

Your main() function must use the following array-of-ints.

   int list[] = { 5, 8, 13, 21, 34 };
   int length = sizeof(list) / sizeof(list[0]);

The main() function keeps making calls to car() and cdr() until the list is empty.

The output of your program should look as follows.

   (car '( 5 8 13 21 34 )) = 5
   (cdr '( 5 8 13 21 34 )) = ( 8 13 21 34 )

   (car '( 8 13 21 34 )) = 8
   (cdr '( 8 13 21 34 )) = ( 13 21 34 )

   (car '( 13 21 34 )) = 13
   (cdr '( 13 21 34 )) = ( 21 34 )

   (car '( 21 34 )) = 21
   (cdr '( 21 34 )) = ( 34 )

   (car '( 34 )) = 34
   (cdr '( 34 )) = ( )