Skip to content

Instantly share code, notes, and snippets.

@achmadweb
Created September 17, 2020 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achmadweb/fb7dd17263ffaf3855afdeb02e445a98 to your computer and use it in GitHub Desktop.
Save achmadweb/fb7dd17263ffaf3855afdeb02e445a98 to your computer and use it in GitHub Desktop.
Contoh program utama dan prosedur untuk menukar 2 buah nilai
#include<stdio.h>
void plus1 (int* a) {
int temp;
*a=*a+1;
}
void plusd (int* a, int d) {
int temp;
*a=*a +d;
}
void swap (int* a, int* b) {
int temp ;
temp= (*a); *a=(*b); *b=temp;
}
int main() {
int i=9;
int x=10;
int y=25;
int d=7;
plus1(&i);
printf ("nilai i+1: %d\n", i);
i=8;
plusd(&i,d);
printf("nilai i+7: %d\n", d);
plusd(&d,3);
printf("nilai d+3: %d\n", d);
printf("nilai x dan y : %d, %d\n", x,y);
swap (&x, & y);
printf ("nilai x dan y setelah swap :%d, %d\n", x,y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment