Advertisement
Guest User

ksm

a guest
Oct 10th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void tukar(int *a, int *b){
  4. int c=*a;
  5. *a=*b;
  6. *b=c;
  7. }
  8.  
  9. int tambah(int a)
  10. {
  11.     return a+7;
  12. }
  13.  
  14. void tambah1(int a){
  15. printf("%d", a+7);
  16. }
  17.  
  18. void tambah2(int *a){
  19. *a=+6;
  20. }
  21. int main(){
  22. int a;
  23. a=5;
  24. int b=7;
  25. int *p=a;
  26. printf("%d\n",p);//alamat p yaitu a
  27. tukar(&a,&b); //tukar a dan b
  28. printf("%i\n%i",a,b);
  29. printf("%d",tambah(a)); //hasil 14
  30. tambah1(a); //print 14 di void/procedure tambah1
  31. tambah2(&a); //ubah nilai a jadi 13 di coid/procedure tambah2
  32. printf("%d",a);
  33. printf("%d",tambah(a)); //hasil 20 karena a udah jadi 13
  34. printf("%d",a); // tetap 13
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement