Use of pointer to access the Array
elements.
#include <stdio.h>
int main ()
{
int marks[] = {60, 70, 80, 90, 100};
int i, *p1;
/* let us use pointer to refer array elements */
p1 = marks;
for ( i = 0; i < 5; i++)
{
printf("Value stored at marks[%d] = %d\n",
i, *p1 );
p1++;
}
return 0;
}
|
Output
of the Program:
Value stored at marks[0] = 60
Value stored at marks[1] = 70
Value stored at marks[2] = 80
Value stored at marks[3] = 90
Value stored at marks[4] = 100
No comments:
Post a Comment