Skip to content

Instantly share code, notes, and snippets.

@LokeshKumarES
Created September 13, 2018 16:27
Show Gist options
  • Save LokeshKumarES/94bb89f96281ebc3d7fd73bd2c3ebd53 to your computer and use it in GitHub Desktop.
Save LokeshKumarES/94bb89f96281ebc3d7fd73bd2c3ebd53 to your computer and use it in GitHub Desktop.
Write a C program to swap the two numbers without using third variable.
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Enter the value of b: ");
scanf("%d", &b);
a=a+b;
b=a-b;
a=a-b;
printf("\nThe value of a is: %d\n", a);
printf("The value of b is: %d", b);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment