Function with arrays means to pass entire values of arrays to the function simultaneously. The example below will show the way of writing programs based on function with an array in C programming.
Example:
Program (1): To display numbers using the concept function with arrays. The numbers are 1, 22, 32, 433 and 15.
#include<stdio.h> #include<conio.h> void main(void) { void display(int num[]); int num[]={1,22,32,433,15}; display(num); getch(); } void display(int b[]) { int i; for(i=0;i<5;i++) { printf("\n%d",b[i]); } }
Output (1)
1 22 32 433 15