Pass pointer to array as argument to function and print content

-- Leave a Comment
Hello here is a short program to Pass pointer to array as an argument to a function and print the content of the function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<stdio.h>
void display (int *a)
{
 int i;
 for(i=0;i<10;i++)
 {
  printf("%d\n",*(a+i));
 }
}
void main()
{
 int data[10]={1,3,5,7,9,2,4,6,8,0};
 display(data);
}

Thats all!

Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University, NCIT. Open Source Enthusiastic.

0 comments:

Post a Comment