• C Program–Arrays with Functions (passing Array elements to function)

    by  • October 20, 2010 • C • 0 Comments


    /*

    Program to demonstrate arrays with function in which the array elements are passed as function parameters

    */

    #include
    #include
    void display(int); //function prototype
    int main()
    {
        int a[10],i;
        for(i=0;i<10;i++) //getting the array elements
        {
        scanf(“%d”,&a[i]);
        }
        for(i=0;i<10;i++)
            display(a[i]); //call the function inside the loop, this function called for 10 times
        getch();
        return 0;
    }

    void display(int a) //function implementation to print the elements, here the parameter is an integer only(means we are passing the array elements)
    {
         printf(“%d”,a);
    }

    Leave a Reply

    Your email address will not be published. Required fields are marked *