Comments

Tuesday, October 16, 2012

Print the Address of THe Array

Posted by at 7:25 AM Read our previous post

Take arrays of type short, int, float and double having 5 elements each. Print addresses of all elements of each array

type. Are these addresses contiguous? Please Comment.

Source code :



#include <iostream>
using namespace std;
int a[]={35,7,11,2,5,3,99,44,23,1};
int count();
int count()
{

       int max,in,out,temp=0;

       for(out=0;out<10;out++)
       {
              for(in=0;in<10;in++)
              {
                     if(a[in]<a[out])
                     {
                           max=a[in];
                           a[in]=a[out];
                           a[out]=max;
                     }
              }
       }
       for(int i=9;i>=0;i--)
       {
              cout<<a[i]<<",";
       }
       return(0);
}
void main()
{
       count();
}


Output:


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template