Created
September 17, 2020 12:42
-
-
Save achmadweb/fb7dd17263ffaf3855afdeb02e445a98 to your computer and use it in GitHub Desktop.
Contoh program utama dan prosedur untuk menukar 2 buah nilai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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