Showing posts with label ARRAY ELEMENTS ARE STORED IN CONTIGUOUS MEMORY LOCATION. Show all posts
Showing posts with label ARRAY ELEMENTS ARE STORED IN CONTIGUOUS MEMORY LOCATION. Show all posts

Saturday, June 16, 2012

63. PROGRAM TO DEMONSTRATE THAT ARRAY ELEMENTS ARE STORED IN CONTIGUOUS MEMORY LOCATION


/*WAP TO DEMONSTRATE THAT ARRAY ELEMENTS ARE STORED IN
  CONTIGUOUS MEMORY LOCATION*/
 #include<conio.h>
 #include<stdio.h>
 void main()
 {
  int x[5]={10,20,30,40,50};
  int i;
  int *ptr;
  ptr=x;
  clrscr();
  for(i=0;i<5;i++)
  printf("\n\nVALUE %d = %d IS STORED AT=%u",i,x[i],ptr+i);
  getch();
  }
/*************************************************************************
    OUTPUT
 *************************************************************************


 VALUE 0 = 10 IS STORED AT=65516

 VALUE 1 = 20 IS STORED AT=65518

 VALUE 2 = 30 IS STORED AT=65520

 VALUE 3 = 40 IS STORED AT=65522

 VALUE 4 = 50 IS STORED AT=65524
 */


                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               

Programming the Whole World!