Monday, September 13, 2010

Accessing array using pointer in c programming language

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

Subscribe via email

Enter your email address:

Delivered by FeedBurner