Created
July 19, 2016 12:32
-
-
Save wohhie/929581f8d3a51f92cfe4dbc427b89bc4 to your computer and use it in GitHub Desktop.
C program to read two integers M and N and to swap their values.
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> | |
//swap function for swaping the value. | |
void swap(int *ptr1, int *ptr2); | |
int main() { | |
int num1, num2; | |
printf("Enter two number: "); | |
scanf("%d %d", &num1, &num2); | |
printf("before swaping M: %d\t N: %d,", num1, num2); | |
printf("\n"); | |
swap(&num1, &num2); | |
printf("after swaping M: %d\t N: %d,", num1, num2); | |
printf("\n"); | |
return 0; | |
} | |
//swap function for swaping the value. | |
void swap(int *ptr1, int *ptr2) { | |
int temp; | |
temp = *ptr1; | |
*ptr1 = *ptr2; | |
*ptr2 = temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment