Navigation

Saturday, 28 February 2015

One Dimensional Array and their address in memory

main()
{
int a[5],*p;
int i,l,n;
clrscr();
printf("enter the length of array::");
scanf("%d",&n);
printf("enter the element in array::\n");
 for(i=0;i<n;i++)
  {
   scanf("%d",&a[i]);
  }
 p=&a[0];
 printf("base address of element is::\n");
 for(i=0;i<n;i++)
   {
     printf("a[%d]=%u\n",i,p++);
   }
   printf("enter the position of element::\n");
   scanf("%d",&l);
   printf("\nbase address of %d is %u",a[l-1],&a[l-1]);
   getch();

   }

No comments:

Post a Comment