Dana Vrajitoru
C201/I211 Computer Programming II

Homework 1

Due Date: Wednesday, September 6, 2006.

Ex. 1 The following three points together compose one program, which should start with the prototypes, followed by the main, and then by the other functions. Include a short example of the execution at the end of the program as a comment.

a) Write a function that searches for the first position (index) of an integer value in an array of integer numbers. If the value cannot be found, the function should return -1. Here is the prototype for this function:

int Search_index(int array[], int size, int value);
b) Write a function that inserts an integer value in an integer array at a given position. Here is the prototype for this function:
void Insert_at_index(int array[], int &size, int value, int index);
Note that the size is a reference parameter and that its value should be modified by the function.

Hint: You must start from the end of the array and shift forwards by one position all the elements from the last to the given index. After you have done this, you can insert the value at that given index.

c) In the main you should do the following: