Guest User

Untitled

a guest
Jan 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int numbers[] = {14, 82, 76, 90, 12, 84};
  6. // Function prototypes
  7. void output_numbers1(int *, int);
  8. void output_numbers2(int *, int);
  9. void output_numbers3(int *, int);
  10.  
  11. // Call the output functions
  12. output_numbers1(numbers, 6);
  13. output_numbers2(numbers, 6);
  14. output_numbers3(numbers, 6);
  15. return 0;
  16. }
  17.  
  18. // Module to print out the array - type 1
  19. void output_numbers1(int *i_ptr, int n) {
  20. // Loop through to print the numbers
  21. for (int i = 0; i < n; ++i) {
  22. cout <<*(i_ptr + i)<<"\t";
  23. }
  24. cout <<endl;
  25. }
  26.  
  27. // Module to print out the array - type 2
  28. void output_numbers2(int *i_ptr, int n) {
  29. // Loop through to print the numbers
  30. int i = 0;
  31. while (i < 6) {
  32. cout <<*i_ptr++<<"\t";
  33. ++i;
  34. }
  35. cout <<endl;
  36. }
  37.  
  38. // Module to print out the array - type 3
  39. void output_numbers3(int i_ptr[], int n) {
  40. // Loop through to print the numbers
  41. for (int i = 0; i < n; ++i) {
  42. cout <<*(i_ptr + i)<<"\t";
  43. }
  44. cout <<endl;
  45. }
Add Comment
Please, Sign In to add comment