Turn Desktop View Off
by Dinesh Thakur

In this program user ask to pass array to function. User declare the variables along with functions for process to pass array like void read (), void dis (). Arguments also declared within function to pass value. Array type variable contains the array elements within. User asks to enter the value as regarding. And then user call the function for passing value to array in a function user declares for loop for to print a value. The other function is been also call and loop statement also declare for another printing method. And display on the screen.

Problem statement:
This is C program that asks user to show how to pass a value on the array through function.

  1. Declaring the variables.
  2. Using functions.
  3. Using loop statements.
  4. Display result on the screen.

Here is C source code for passing array to function. Output of this program shown below. 

#include<stdio.h>
#include<conio.h>
void read(int *,int);
void dis(int *,int);
void main()
   {
         int a[5],b[5],c[5],i;
         clrscr();
         printf("Enter the Elements of First List :");
         read(a,5);
         printf("The Elements of First List are : ");
         dis(a,5);
         getch();
   }
         void read(int c[],int i)
      {
            int j;
           for(j=0;j<i;j++)
               scanf("%d",&c[j]);
               fflush(stdin);
      }
         void dis(int d[],int i)
     {
            int j;
            for(j=0;j<i;j++)
                 printf("%d ",d[j]);
                 printf("\n");
     } 

Pass Array to Function