How to implement array in C++ plus plus using function.

Total Post:70

Points:350
 814  View(s)
Ratings:
Rate this:
  1. Post:70

    Points:350
    How to implement array in C plus plus using function.

    For the array implementation using function there is no need of any return type of function because address will be pass through the function. Any changes made in the function will directly reflect the main program.


    #include <iostream>

    using namespace std;

        void stored(int *x, int n);

        void printed(int *y,int z);

        int main()

    {

        int num[10];

        int max = 5;

        stored (num,max);

        printed(num,max);

    }


    void stored(int *x, int n)

    {

    int i;

    for(i=0;i<n;i++)

    {

    cout <<"Enter the element "<<i<<endl;

    cint>>x[i];   

    }

    }

    void printed(int *x, int n)

    {

    int i;

    for(i=0;i<n;i++)

    {

    cout <<"Element :"<<x[i]<<endl;

    */cout << "*(x + " << i <<") : ";

          cout << *(x + i) << endl; // We can also use this statement to print the output.

    */

    }

    }

      Modified On Mar-29-2018 12:09:00 AM

Answer