AbdulFathaah

array using pointers

Nov 13th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. /* array using pointers */
  2.  
  3. #include<conio.h>
  4. #include<stdio.h>
  5.  
  6. int main()
  7. {
  8. int a[10],i,*ptr,n;
  9. clrscr();
  10. printf("Enter number of elments:\n");
  11. scanf("%d",&n);
  12. ptr=&a;
  13. printf("Enter array elements:\n");
  14. for(i=0;i<n;i++)
  15. {
  16. scanf("%d",ptr+i);
  17. }
  18. printf("The Array is:\n");
  19. for(i=0;i<n;i++)
  20. {
  21. printf(" %d",*(ptr+i));
  22. }
  23. printf("\nThe Array Address is:\n");
  24. for(i=0;i<n;i++)
  25. {
  26. printf(" %u",(&ptr+i));
  27. }
  28. getch();
  29. return 0;
  30. }
  31.  
  32. 
Advertisement
Add Comment
Please, Sign In to add comment