Exams:

MAKAUT BTech CSE

Answer:

A pointer is a variable that stores the address of some other variable, instead of data. An integer variable can store some integer value, but an integer type pointer variable can only hold the address of an integer variable. We can also access and change the value of the integer variable using the pointer.

Explanation

The “data” stored within a pointer variable is considered as an “address”.

“37, M. N. Sen Street, Kolkata 700001 ” – Is it an address or data?

When we see the above text on an envelope, the text is considered to be an address. But, if we see the same text on someone’s driving license or Adhar Card, the same text is considered to be data. Similarly, The data stored within a pointer variable is a Hexadecimal number which represents the address of some variable.

Example:

The following code snippet shows how to use a pointer.

int main(){
    int x;  // creating an integer
    int *p; // creating a pointer to integer variable
    x = 5;
    p = &x;
    printf("x contains %d at location %x", x , &x);
    printf("\n");
    printf("p contains %x at location %x", p , &p);
    printf("\nAccessing x via p:-\n");
    printf("value of x is %d", *p);
    return 0;
}
sample-output

Related Question:

  1. What is the address of any variable?
  2. Can a pointer variable store values?
  3. What type of values can be stored in a pointer variable?
  4. Can we perform addition or subtraction on pointers?
  5. What is the use of * while using pointers in C?

0 Replies to “What is a pointer variable in C?

  1. Dichaelabell
    Доброго дня!
    Диплом постепенно улучшается с каждым днем благодаря использованию найденных ресурсов в интернете.
    Закажите диплом у нас и получите его быстро и надежно, оплата после получения, доставка в любой регион РФ.
    Желаю каждому прекрасных оценок!
    купить диплом в озёрске
    купить морской диплом
    купить диплом в новочебоксарске
    купить диплом в клинцах
    купить диплом биолога

    купить диплом повара-кондитера
    купить диплом архитектора
    купить дипломы о высшем
    купить диплом логиста
    купить диплом вуза

Leave a Reply

Your email address will not be published. Required fields are marked *