Computer Programming

Question 1. Write a program that defines a function called getArray. This function should take no parameters. It should ask the user to enter 10 integers separated by a space and store them in an array called a inside the function. The function should return a pointer to the array.
The main function should call the function getArray, and print out the contents of a.
Sample output:
enter 10 integers separated by space:
1 2 3 4 5 6 7 8 6 6
1 2 3 4 5 6 7 8 6 6
You will notice that you might get a compiler warning like the following:

week5_1s.c: In function ‘getArray’:
week5_1s.c:17:4: warning: function returns address of local variable [-Wreturn-local-addr]
return a;
^

This is because inside the function getArray, the array a needs to be static, like this:
static int a[10];
See “static local variables”

Question 2. Write a C program that creates an array with 10 integers. Each element should be equal to 8 times its index. So a[0] should be 0, a[1] should be 8, a[2] should be 16, etc.
The program should print out the array in a while loop, using pointer arithmetic to access each element.
Question 3. Write a program that asks the user for 10 integers separated by a space and stores these in an array. The array should be passed to a void function called changeArray that multiplies each element by 10. The main function should then print out the changed array.
Sample output:
enter 10 integers separated by space:
1 2 3 4 5 6 7 8 9 10
10 20 30 40 50 60 70 80 90 100