For Advertisements on this blog Contact Us at developgram@gmail.com or +91-9923438816

Simple Programming Tutorials For Beginners

Sunday, December 11, 2016

Swap Numbers

/*
Summary: Swap two numbers without using third number.
*/

#include <stdio.h>
int main()
{
 int a,b;

 printf("Enter a and b");
 scanf("%d",&a);
 scanf("%d",&b);

 printf("Before Swapping a=%d,b=%d",a,b);
 a=a+b;
 b=a-b;
 a=a-b;

 printf("After Swapping a=%d,b=%d",a,b);

 return 0;
}

No comments:

Post a Comment

SEARCH THIS BLOG