Fill in the blanks of the following table Char cp cMAX int I

Fill in the blanks of the following table. Char *cp, c[MAX], int I;

Solution

The Statement char *cp,c[max];int i; belongs to the declaration of variables

char *cp is a pointer variable i.e which stores the address of another variable

c[max] is a array declaration i.e it stores values in a continuous memory locations

& opearator represents the address of a variable.

Suppose say a variable is declared as int x; now variable x holds some address in the memory. &x gives the address of the variable x in the memory.

pointer variables stores a value as address of another variable and interprets them suppose char *ch is a pointer variable

int x=5;

ch= &x;//address of x say 5678

printf(ch)//5678

print(*ch) //5

ARRAYS:

Arrays are the continuous block of memory staring at index 0 to max-1

Code :

In the above code as the variable c is declared as array so C or C[0] are the same since index begins at zero by default.now c+i gives the ith location in the memory since array is a continous block of memory. in array notation we write it as &c[i].

now we wanted to print the value of ith position then the array will be cp[i]

where as in case of pointers it is *(cp+i) because * (variable) gives the value of a particular location.

 Fill in the blanks of the following table. Char *cp, c[MAX], int I; SolutionThe Statement char *cp,c[max];int i; belongs to the declaration of variables char *

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site