Posts

Showing posts with the label pointer in c

Pointer Program #1

Image
10. Read n numbers in an array and print them using pointer. #include<stdio.h> void main () {      int n,i,*p,array[100];      p=array;      printf("Enter size of array:\n");      scanf("%d",&n);      printf("Enter elements of array:\n");      for(i=0;i<n;i++)      {           scanf("%d",p+i);      }      printf("The array using pointer is:\n");      for(i=0;i<n;i++)      {           printf("%d\n",*(p+i));      } } Output Enter size of array: 5 Enter elements of array : 12 13 14 15 16 The array using pointer is: 12 13 14 15 16 Note: The above method uses array notation to print elements. You can also use poi...