728x90 AdSpace

Latest Article



Using Pointer in Loop C++ Example with Code





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]<<" ";

1 2 3 4 5 6 7 8 9 10
 
 




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]<<" "; 

10 1 2 3 4 5 6 7 8 9

 
 







no image






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment