posted Jan 5, 2011, 9:05 AM by Neil Mathew
[
updated Mar 15, 2011, 1:54 AM
]
SOURCE CODE:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| #include<stdio.h>
void Input(int *p) //Using Pointers
{
int i=0;
for(i=0; i<5; i++)
scanf("%d", (p+i));
//scanf("%d", &(*(p+i)));
//scanf("%d", &p[i]);
}
void Display(int p[]) //Passing Array
{
int i=0;
for(i=0; i<5; i++)
printf(" \n A[%d] : %d ", i,*(p+i));
//printf(" \n A[%d] : %d ", i,p[i]);
}
main()
{
int a[6];
printf(" Enter Elements: \n");
Input(a);
printf(" Display: ");
Display(a);
}
|
OUTPUT:
Enter Elements: 5 6 5 8 5
Display:
A[0] : 5
A[1] : 6
A[2] : 5
A[3] : 8
A[4] : 5 |
|