///////////////////////////////////////////////////////////////////
//  Some examples of operations on arrays shown in class
///////////////////////////////////////////////////////////////////

#define SIZE 20

int x[SIZE], y[SIZE], z[SIZE}, i, t;

// Initialize all array elements to a value:
void initArray(int x[], int size, int value) {
	int i;
	for (i=0; i<size; i++) {
		x[i] = value;
	}
}
initArray(z, SIZE, 42);		// Example of how to call the function

// Add one to all elements in array:
void plusOne(int x[], int size) {
	int i;
	for (i=0; i<size; i++) {
		x[i]++;
	}
}
plusOne(z,4);		// Example of how to call the function

// Print all elements of an array	
void printArray(const int x[], int size)	 {
	int i;
	for (i=0; i<size; i++) {
		printf("Value of x[%d] is %d\n", i, x[i]); 
	}
}
printArray(z, 3);		// Prints the first three elements of the arrays
printArray(&z[0], 3); 	// Same
printArray(&z[3], 3)	// Prints the next three elements

// Input elements of an array
void inputArray(int x[], int size) {	
	int i;
	for (i=0; i<size; i++) {
		scanf("%d", &x[i]);		// Note & and [] are both operators
	}
}
inputArray(z,5);		// Example of how to call the function

// Shift the elements of an array down one
void shiftDownArray(int x[], int size) {	
	for (i=0; i<size-1; i++) {		// note SIZE-1
		x[i] = x[i+1];
	}
}
shiftDownArray(z,5);		// Example of how to call the function

// Shift the elements of an array up one
void shiftUpArray(int x[], int size) {	
	for (i=size-1; i>0; i--) {		// note bounds on i
		x[i] = x[i-1];
	}
}
shiftUpArray(z,5);		// Example of how to call the function

// Copy arrays
	x = y; 		// Error - does not work in C!

void copyArray(int x[], const int y[], size) {
	int i;
	for (i=0; i<size; i++) {
		x[i] = y[i];
	}
}






