-->

Program to show pointer for increment and decrement operator.

using codeblocks
---------------------------------------------------------------------------

//understanding pointer  increment and decrement              //comment of program
#include <stdio.h>                     //header file
int main()
{
    int *pointer;                      //pointer declaration
    int x=4;                           //value assignment
    pointer=&x;                        //assigning address to that pointer
    printf("the address of x is=%d\n",pointer);//display of that address
    printf("the  value of x=%d\n",*pointer);    //display of value stored in that address. we display that using indirection operator
   pointer++;                             //increment of address by 1
   printf("pointer ++=%d\n",pointer);       //display of that address
   pointer--;                            //pointer decrement
   printf("pointer --=%d",pointer);       //display of that address

    return 0;
}


-------------------------------------------------------------------------------------------------------------
using turboc++
----------------------------------------------------------------------------------------------------------
//understanding pointer  increment and decrement              //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    int *pointer;                      //pointer declaration
    int x=4;                           //value assignment
    pointer=&x;                        //assigning address to that pointer
    printf("the address of x is=%d\n",pointer);//display of that address
    printf("the  value of x=%d\n",*pointer);    //display of value stored in that address. we display that using indirection operator
   pointer++;                             //increment of address by 1
   printf("pointer ++=%d\n",pointer);       //display of that address
   pointer--;                            //pointer decrement
   printf("pointer --=%d",pointer);       //display of that address
  getch();                                           //to hold the output
    return 0;
}

No comments:

Post a Comment