Last active
June 1, 2019 18:46
-
-
Save chankruze/4bdaa12bdf75bc1f67fcd8dbc9ccf7f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 swap(int *, int *); // The right way is to declare function prototype in header. | |
int main() | |
{ | |
int a, b; | |
// printf("Enter the value of a:\n"); | |
// scanf("%d", &a); | |
// printf("Enter the value of b:\n"); | |
// scanf("%d", &a); | |
a = 10; | |
b = 20; | |
printf("[I] Before Swapping\n"); | |
printf("==> a = %d\n", a); | |
printf("==> b = %d\n", b); | |
swap(&a, &b); | |
printf("\n[I] After Swapping\n"); | |
printf("==> a = %d\n", a); | |
printf("==> b = %d\n", b); | |
return 0; | |
} | |
void swap(int *a, int *b) | |
{ | |
int temp = *a; | |
*a = *b; | |
*b = temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment