Pages

Saturday, March 29, 2014

C Program to swap two numbers without using temp

/* to swap two numbers without using temp */
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b;
    printf("Enter first number: ");
    scanf("%d",&a);
    printf("Enter second number: ");
    scanf("%d",&b);
    a=a+b;
    b=a-b;
    a=a-b;
    printf("The first number: %d\n",a);
    printf("The second number: %d\n",b);
    system("pause");
    return 0;
}

No comments:

Post a Comment