Using Pointer in Loop C++ Programming Example question with solution with Code
1.
What will be the output of this code?
int a[10];
int *p=a;
for(int i= 0;i<10;i++)
a[i]=i+1;
for(int i= 0;i<10;i++)
cout<<p[i]<<" ";
|
2.
What will be the output of this code?
int *a;
a=new int[10];
int *p=a;
for(int i= 0;i<10;i++)
a[i]=i;
p[0]=10;
for(int i= 0;i<10;i++)
cout<<a[i]<<"
";
|
0 comments:
Post a Comment