Monday, September 12, 2011

Addition and subtraction using pointer

addition & subtraction of a number from a pointer

#include<stdio.h>
#include<conio.h>
main()
{
    int a[]={10,20,30,40,50};
    int *j,*k;
    clrscr();
    j=a;   // or j=&a[0];
    k=a+4;  // or k=&a[4];
    printf("\n %d %d",*j,*k);
    j=j+2;
    k=k-1;
    printf("\n %d %d",*j,*k);
    getch();
    }

No comments:

Post a Comment

Popular 5 Posts Last 7 days