/* Pointer and Arrays */
#include<iostream.h>
#include<conio.h>
main()
{
int a[5],*p,i;
clrscr();
p=a;
*(a+0)=100;
a[1]=200;
a[2]=300;
a[3]=400;
a[4]=500;
p[0]=1000;
*(p+1)=2000;
for(i=0;i<5;i++)
cout<<"\n Value of Array :"<<a[i];
for(i=0;i<5;i++)
cout<<"\n Value of Pointer :"<<*(p+i);
getch();
}
#include<iostream.h>
#include<conio.h>
main()
{
int a[5],*p,i;
clrscr();
p=a;
*(a+0)=100;
a[1]=200;
a[2]=300;
a[3]=400;
a[4]=500;
p[0]=1000;
*(p+1)=2000;
for(i=0;i<5;i++)
cout<<"\n Value of Array :"<<a[i];
for(i=0;i<5;i++)
cout<<"\n Value of Pointer :"<<*(p+i);
getch();
}
No comments:
Post a Comment