WARNING AND NOTICE

All tricks in this blog are only for educational purpose. Learn these tricks only for your knowledge. Please donot try these to harm any one. We will not take any responsibility in any case. All softwares and tools on this site are here for private purposes only and If you want to use a software for business purpose, please purchase it. I do not host many of these tools. I Post links that I have found from numerous Search engines. I will not be responsible for any of harm you will do by using these tools.

Readmore

Thursday, September 23, 2010

C (Pointer Concepts, Pointers/Arrays Concepts)

Problem #1 [20 POINTS]: POINTER CONCEPTS1. (3 points) Given the following function declaration, answer the questions that follow: void foo(const int *p); (a) Can the function foo modify its argument p? Can it modify what p points to? Explain.(b) Is the following a legal function declaration? Explain its meaning. void foo(int * const p); (c) Is the following a legal function declaration? Explain its meaning. void foo(const int * const p); 2. (3 points) Given the following declarations, circle which expressions are valid aliases for i: int i = 10, *p = &i, *q = &i; (a) *p(b) &p(c) *&p(d) &*p(e) *i(f) &i(g) *&i(h) &*i 1/13 CSc 352 (Summer 05)Systems Programming and UNIX 3.(3 points) The following function is supposed to compute the sum and average of the floating pointnumbers in the array a, which has length n. avg and sum are supposed to be pointers to variables thatthe function should modify. Unfortunately, this function contains several errors. Find and correct them. avg_sum(int a[], n, float *avg, *sum){sum = 0.0;for (int i = 0; i < avg =" sum" 12345 ="=""> 3 hr(s) 25 min(s) 45 sec(s) void split_time(long int total_sec, int *hr, int *min, int *sec){} 2/13 CSc 352 (Summer 05)Systems Programming and UNIX 5.(2 points) Write the function void minmax(int a[], int *min, int *max) that puts the minimumvalue of the array into the variable pointed to by min and the maximum value into the variable pointedto by max.6.(3 points) Write a function which takes an array of integers, the length of the array, as well as twopointers – one to store the largest value into, and one to store the second largest value into. void find_two_largest(int a[], int n, int *largest, int *second_largest).

Download C (Pointer Concepts, Pointers/Arrays Concepts).

0 comments:

Post a Comment