Advertisement
alkelane7

mohamed

Mar 16th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<iostream.h>
  2.  
  3.  
  4. void Reverse_Array(int array[],int size);
  5.  
  6. void main()
  7. {
  8. int i,a[10],size;
  9.  
  10. cout<<"Enter size of Array ( Max:10 ): ";
  11. cin>>size;
  12. cout<<"\nEnter any "<<size<<" elements: \n";
  13.  
  14. for(i=0; i<size; i++)
  15. {
  16. cin>>a[i];
  17. }
  18.  
  19. cout<<"\nStored Data in Array: \n\n";
  20.  
  21. for(i=0;i<size;i++)
  22. {
  23. cout<<" "<<a[i]<<" ";
  24. }
  25. // Calling Reverse Array Values Function
  26. Reverse_Array(a,size);
  27. cout<< "\n\nReversed Array Elements are: \n\n";
  28. for(i=0;i<size;i++)
  29. {
  30. cout<<" "<<a[i]<<" ";
  31. }
  32. cout<<"\n";
  33.  
  34. }
  35.  
  36. //------Reverse Array Function---------------
  37.  
  38. void Reverse_Array(int array[],int size)
  39. {
  40. int temp;
  41. size--;
  42. for (int i=0;size>=i;size--,i++)
  43. {
  44. temp=array[i];
  45. array[i]=array[size];
  46. array[size]=temp;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement