2/21/2009

C Program To Swap Of Two Numbers



    /*Write a c program to exchange of
    two numbers using temporary variable */
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,temp ;
    printf("Enter two numbers:\n");
        scanf("%d%d",&a,&b);
    printf("Numbers before swapping A= %d , B= %d \n",a,b);
    temp=b;
    b=a;
    a=temp;
    printf("Numbers after swapping A= %d , B= %d \n",a,b);
    return 0;
}
Out Put:
Enter two numbers:
98
56
Numbers before swapping A= 98 , B= 56
Numbers after swapping A= 56 , B= 98

No comments:

Post a Comment