0
48kviews
What is a pointer? Explain how the pointer variable declared and initialized.

Subject : Structured Programming Approach

Title : Pointers and Files

Difficulty : Medium

1 Answer
3
14kviews

Pointer is a variable used to store the address of another variable or a memory location. It always stores a integer since it shares an address.

Pointer is declared and initialzed as shown in the following program;

Program:

#include<stdio.h>
#include<conio.h>

int main() {
    int* ptr; // pointer declaration
    int a;
    ptr = &a; // pointer initialization

    printf("\n\n\t Value of a = %d", *ptr);;

    getch();
    return 0;
}

Pointer is declared using special character '*' along with datatype pointer points and name of the pointer as an identifier. Pointer initialization is a programming technique in which pointer is assigned an address of a varible so that pointer points to specific value.

Please log in to add an answer.