Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void print(int x[10],int n);
  4. void rprint(int x[10],int n);
  5. void marray(int x[10],int n);
  6. void mrarray(int x[10],int n);
  7. int main()
  8. {
  9. int a[10];
  10. int i;
  11. int n;
  12. cout<<"how many array elements? n=";
  13. cin>>n;
  14. cout<<"enter data :"<<endl;
  15. for(i=0;i<n;i++)
  16. {
  17. cout<<"a["<<i<<"]=";
  18. cin>>a[i];
  19. }
  20. print(a,n);
  21. rprint(a,n);
  22. marray(a,n);
  23. mrarray(a,n);
  24. return 0;
  25. }
  26. void marray(int x[10],int n)
  27. {
  28. int i;
  29. cout<<" array multiplied by 3 ,then contents are :"<<endl;
  30. for(i=0;i<n;i++)
  31. {
  32. cout<<"x["<<i<<"]="<<x[i]*3<<endl;
  33.  
  34. }
  35.  
  36. }
  37. void print(int x[10],int n)
  38. {
  39. int i;
  40. cout<<" array contents are :"<<endl;
  41. for(i=0;i<n;i++)
  42. {
  43. cout<<"x["<<i<<"]="<<x[i]<<endl;
  44.  
  45. }
  46. }
  47. void rprint(int x[10],int n)
  48. {
  49. int i;
  50. cout<<"reversing the array elements"<<endl;
  51. for(i=n-1;i>=0;i--)
  52. {
  53. cout<<"x["<<i<<"]="<<x[i]<<endl;
  54. }
  55. }
  56. void mrarray(int x[10],int n)
  57. {
  58. int i;
  59. cout<<"reversing of multiplied array elements"<<endl;
  60. for(i=n-1;i>=0;i--)
  61. {
  62. cout<<"x["<<i<<"]="<<x[i]*3<<endl;
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement