Thursday, 11 September 2014

Write a program to do swapping of two numbers using third variable.

#include<stdio.h>

main()
{
    int a,b,c;
    printf("\nEnter two numbers=");
    scanf("%d%d",&a,&b);
    printf("\nBefore swapping");
    printf("\na=%d,b=%d",a,b);
    c=a;
    a=b;
    b=c;
    printf("\nafter swapping");
    printf("\na=%d,b=%d",a,b);
}

No comments:

Post a Comment