Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int numbers[] = {14, 82, 76, 90, 12, 84};
- // Function prototypes
- void output_numbers1(int *, int);
- void output_numbers2(int *, int);
- void output_numbers3(int *, int);
- // Call the output functions
- output_numbers1(numbers, 6);
- output_numbers2(numbers, 6);
- output_numbers3(numbers, 6);
- return 0;
- }
- // Module to print out the array - type 1
- void output_numbers1(int *i_ptr, int n) {
- // Loop through to print the numbers
- for (int i = 0; i < n; ++i) {
- cout <<*(i_ptr + i)<<"\t";
- }
- cout <<endl;
- }
- // Module to print out the array - type 2
- void output_numbers2(int *i_ptr, int n) {
- // Loop through to print the numbers
- int i = 0;
- while (i < 6) {
- cout <<*i_ptr++<<"\t";
- ++i;
- }
- cout <<endl;
- }
- // Module to print out the array - type 3
- void output_numbers3(int i_ptr[], int n) {
- // Loop through to print the numbers
- for (int i = 0; i < n; ++i) {
- cout <<*(i_ptr + i)<<"\t";
- }
- cout <<endl;
- }
Add Comment
Please, Sign In to add comment