Thursday, 20 March 2014

Write a C program to exchange two numbers using temporary variable.

#include<stdio.h>

main()
{
    int a,b,temp;
    printf("\nEnter two numbers=");
    scanf("%d%d",&a,&b);
    printf("\nBefore exchange a=%d,b=%d",a,b);
    temp=a;
    a=b;
    b=temp;
    printf("\nAfter exchange a=%d,b=%d",a,b);
}

No comments:

Post a Comment