fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a = 10;
  5. int *p1 = &a;
  6. float f = 5.25;
  7. float *p2 = &f;
  8. char c = 'A';
  9. char *p3 = &c;
  10. double d = 9.876;
  11. double *p4 = &d;
  12. printf("INTEGER POINTER:\n");
  13. printf("Value of a : %d\n", a);
  14. printf("Pointer p1 (address of a): %p\n", p1);
  15. printf("Address of p1 itself : %p\n", &p1);
  16. printf("Value pointed by p1 (*p1): %d\n\n", *p1);
  17. printf("FLOAT POINTER:\n");
  18. printf("Value of f : %.2f\n", f);
  19. printf("Pointer p2 (address of f): %p\n", p2);
  20. printf("Address of p2 itself : %p\n", &p2);
  21. printf("Value pointed by p2 (*p2): %.2f\n\n", *p2);
  22. printf("CHAR POINTER:\n");
  23. printf("Value of c : %c\n", c);
  24. printf("Pointer p3 (address of c): %p\n", p3);
  25. printf("Address of p3 itself : %p\n", &p3);
  26. printf("Value pointed by p3 (*p3): %c\n\n", *p3);
  27. printf("DOUBLE POINTER:\n");
  28. printf("Value of d : %.3lf\n", d);
  29. printf("Pointer p4 (address of d): %p\n", p4);
  30. printf("Address of p4 itself : %p\n", &p4);
  31. printf("Value pointed by p4 (*p4): %.3lf\n", *p4);
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
INTEGER POINTER:
Value of a               : 10
Pointer p1 (address of a): 0x7ffd7476aa98
Address of p1 itself     : 0x7ffd7476aaa0
Value pointed by p1 (*p1): 10

FLOAT POINTER:
Value of f               : 5.25
Pointer p2 (address of f): 0x7ffd7476aa9c
Address of p2 itself     : 0x7ffd7476aaa8
Value pointed by p2 (*p2): 5.25

CHAR POINTER:
Value of c               : A
Pointer p3 (address of c): 0x7ffd7476aa97
Address of p3 itself     : 0x7ffd7476aab0
Value pointed by p3 (*p3): A

DOUBLE POINTER:
Value of d               : 9.876
Pointer p4 (address of d): 0x7ffd7476aab8
Address of p4 itself     : 0x7ffd7476aac0
Value pointed by p4 (*p4): 9.876