Program to illustrates Passing an entire Array to a Function


#include<iostream.h>
#include<conio.h>
void display( int*, int ) ;
void main( )
{
    int number [ ] = { 11, 22, 33, 44, 55 } ;
    display (&number[0], 5); 
}

void display (int *j , int n)
{
                    for (int i = 0; i <= n-1 ; i++)
                    {
                          cout<<"\n Element : "<< *j ;
                          j ++;       //increment pointer to point to next location
                    }
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|