Array to pointer program

 Instagram                              Twitter                        YouTube                 Facebook

{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

--------------------------------------------------------------------------------------------------------------------

Question: Write a program to access element of an array by using pointers.

--------------------------------------------------------------------------------------------------------------------

credit this program coding_by_ak

Program:
                #include<stdio.h>
                #include<conio.h>
                void main (void)
                {
                     int *ptr;
                    int arr[10],i;
                    clrscr();
                    for (i=0; i<10; i++)
                    {
                        scanf("%d", &arr[i]);
                    }
                        ptr=&arr[0];
                        for (i=0; i<10; i++)
                        {
                            printf("%d\t", *(ptr+i));
                        }
                        getch();
                 }


{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

BCA,                    Programming C,                    Allrounder Sita Ram Sahu,            Blogspot.com

}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

No comments:

Post a Comment