Wednesday, August 08, 2012

Program to input data into an array and then to print on the screen by using pointers as function arguments

Program to input data into an array and then to print on the screen by using pointers as function arguments
output

void display(int *);
void main(void) {
  int i,arr[5];
  cout<<"\nInput:\n";
  for(i=0;i<5;i++) {
  cin>>arr[i];
  }
  display(arr);
}
void display(int *ptr) {
  cout<<"\nOutput:\n";
  for(int i=0;i<5;i++) {
  cout<<*ptr<<endl;
  ptr++;
  }
}