/*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
*/
No comments:
Post a Comment