Code for swapping in c

Posted By: Matpal - January 25, 2012
#include<stdio.h>
int main(){
    int a,b,temp;
   
    printf("Enter any two integers: ");
    scanf("%d%d",&a,&b);
    printf("Before swapping: a = %d, b=%d",a,b);

    temp = a;
    a = b;
    b = temp;
    printf("\nAfter swapping: a = %d, b=%d",a,b);

    return 0;
}

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.