C Chapters

C program to passing the array into function.

Passing Arrays to Functions - Functions
#include <stdio.h>

void disp( char ch)
{
   printf("%c ", ch);
}

int main()
{
   char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
   for (int x=0; x<10; x++)
   {
       /* Passing each element one by one using subscript*/
       disp (arr[x]);
   }
   return 0;
}

Output :
a b c d e f g h i j

Leave a comment
Recent Comments
No Comments