/* * Assignment * Chapter 10 * By John Stile */ 1) How are each of the following evaluated? STATMENT: EXPLANATION: 1a) float * aaa // declare pointer to a float named aaa 1b) bbb = &ccc // assign address of ccc to bbb 1d) ddd = *eee // assign the value pointed to by eee to ddd 1e) return &fff // return address of fff to calling function 1f) *pgg+=1; // increment thing pointed to by pgg by one 1g) phh ++; // increment phh by one. // if phh is a pointer, moves over by size of it's data type. 1h) printf(" %p \n", &pbb); // Print address of pbb 1i) int * ffgghh(int * paa, int * pbb) // header for funtion ffgghh: // takes 2 int pointers, // returns 1 int pointer 2) For each of the following, write a single statement. a. Declare the variable bbbb to point to an object of type float. ANSWER: float * bbbb; b. Assign the address of the variable hhhh to integer variable pnum. ANSWER: int * pnum = &hhhh; c. Print the value of the object pointed to by pnum. ANSWER: printf("Value at pnum is %d\n", *pnum); d. Increment the value of the object pointed to by pnum by 5. ANSWER: *pnum+=5; e. Print the address of num using pnum. ANSWER: printf("The address of num is %p\n", pnum); f. Change the value of num to 33 using pnum. ANSWER: *pnum=33; 3) Write the code for a short program that has 3 float variables, pointed to by ponters. Use the pointers to modify the values in the three variables. ANSWER: See Assignment.question3.c