Program on accessing array using pointer
In this program we will accept five numbers from the user and store them in an array and the values will be displayed through pointer.
#include< stdio.h >
void main ()
{
int num [5];
int i, *ptr;
clrscr ();
printf ("Enter the five numbers:-");
for (i=0;i< 5;i++)
{
scanf ("%d", &num [i]);
}
ptr=num;
printf ("\nThe numbers are:-");
for (i=0;i< 5;i++)
printf ("%d ", *ptr++);
getch ();
}
No comments:
Post a Comment