Question & Answer: Write an appropriate declaration for each of the following situations involving pointers. (a) Declar…..

1. Write an appropriate declaration for each of the following situations involving pointers. (a) Declare a function that accepts an argument which is a pointer to an integer quantity and returns a character. iT

in C please

Write an appropriate declaration for each of the following situations involving pointers. (a) Declare a function that accepts an argument which is a pointer to an integer quantity and returns a character. (b) Declare a function that accepts an argument which is an integer array and returns a character.

Expert Answer

 

Hi,
there is just a subtle difference between passing a i

nteger pointer and integer array, look below,
a) char fun(int *quantity)
and while calling you should be giving the address of the variable like fun(&n);
b) now, to pass an integer array, 2 options are there, you can pass the exact same like above i.e
char fun( int *a) OR
char fun( int a[])
both are identical;
arrays cannot be passed by value,
the difference comes in both a and b is how you are defining the passig value.
for example in a. you can right
int n;
and call fun(&n) – here you are passing an integer pointer
for b
int a[]={0,0}
fun(a) — here you are passing the integer array.

Still stressed from student homework?
Get quality assistance from academic writers!