OUTPUT (after running):
Enter any 5 integers: 1 2 3 4 5
Array elements are:
1
2
3
4
5
Explanation:
Here we have used two functions—aread( ) and adisplay( )—to read an integer
array and to display its elements, respectively. Their prototypes are as follows:
void aread(int *, int);
void adisplay(int *, int);
It is said to be the pointer variable notation. You can also use the following notations while declaring
an array pointer parameter:-
void aread(int aptr[ ] , int n)
{
for(int i=0; i scanf(“%d”, &aptr[i];
}
void adisplay(int aptr[ ] , int n)
{
for(int i=0; i scanf(“%d \n”,& aptr[i]);
}
NOTE
There is no difference between the earlier notations and the later notations. They both
work in the same way. The only difference between the former and latter notation is that
in the former:
Do'stlaringiz bilan baham: |