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


(以上发布均为题目,为保证客户隐私,源代码绝不外泄!!)

程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: t[email protected]  微信:dmxyzl003 工作时间:全年无休-早上8点到凌晨3点


如果您用的手机请先保存二维码到手机,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

 

发表评论