Basic Program

0 June 15, 2021

In this example, We will learn a simple program for pointer. Before that, You must have knowledge of the following topics.

Download Application: Learn C Programming with Live Compiler

Few Notes to remember:

  • * is used to access the value stored in the pointer variable
  • & is used to store the address of the given pointer

CODE

#include <stdio.h>

int main()
{
    
    int var = 24;   // actual variable declaration
    int *p;

    p = &var;   // storing address of int variable var in pointer p

    printf("\n\nAddress of var variable is: %x \n\n", &var);

    // address stored in pointer variable
    printf("\n\nAddress stored in pointer variable p is: %x", p);

    // access the value using the pointer variable
    printf("\n\nValue of var variable or the value stored at address p is   %d ", *p);

    return 0;
}

the output of above code is

Address of var variable is: 61ff18

Address stored in pointer variable p is: 61ff18

Value of var variable or the value stored at address p is   24
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System