Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write declarations for each of the following variables: a. amounts is an array o

ID: 3621374 • Letter: W

Question

Write declarations for each of the following variables:

a. amounts is an array of 8 longs

b. net_inc is an array of 12 floats

c. daily_tot is an array of 12 arrays of 31 ints

d. names is an array of 12 pointers to arrays of 50 char



Given that pi and pj are pointers to int, and ii and ij are ints, which of the following expressions are valid?

a. pi + ii

b. pi + pj

c. pi++

d. pi - ii

e. pi - pj


Write your own definition of strcpy() using array notation. (This means write the code that implements the function. Refer to Appendix B for the strcpy() function prototype.)


Write your own definition of strcpy() using pointer notation.


Write a declaration, including arguments and result, for a two-dimensional version of strlen, that is, a function that receives an array of pointers to char and an array of size_t integers, and an int that specifies the number of elements in each array. (You don't need to write the actual function.)

Write a function void shift(char *) that looks at the first character of its argument and converts the other characters, to be the same case, that is, if the first character is uppercase, it shifts the rest to uppercase; if the first character is lowercase, it shifts the rest to lowercase, and otherwise, it does nothing.

Explanation / Answer

In order to declare arrays in C, you must declare the type, name, and size. For example, an array of 25 integers would be declared: int numbers[25]; Valid Expressions: Adding two pointers without using the dereference operator (*) simply adds the addresses. So if pi points to an integer 5 stored at memory location 1000 and pj points to an integer 10 at memory location 1016... pj+pi would equal 2016 but *pj+*pi would equal 15 Along these same lines... incrementing a pointer increments the ADDRESS, not the value it points to. In order to add two things, they must be of the same type. So if xptr is a pointer to an integer and y is an integer... xptr + y is not valid, however *xptr + y would be because the dereferencing operator accesses the integer value rather than the pointer.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote