here's the code:
int *num_arr = number_to_array(num);
cout<<"\nNum aaray:"<<*(num_arr+1);
display(num_arr, digit_count);
The cout statement here is showing the correct value, but display() is not. display is showing garbage values
code for display():
void display(int num_arr[],int dc)
{
cout<<"\n";
cout<<"\n"<<num_arr[0];
cout<<"\n"<<num_arr[1];
 for(int i = (dc-1); i>=0; i--)
 {
         cout<<num_arr[i];
 }
}
int* number_to_array(int num)
{
int i=0;
int num_arr[100]; // make dynamic array
  while(num!=0)
  {
    num_arr[i] = num%10;
    num  = num/10;                
    i++;
   }
return num_arr;
}
what could be the reason?
 
     
    