Write a program to swap two numbers without using third variable?

#include <stdio.h>

int main()
{
int i,j,k;
printf(” Enter value of i “);
scanf(“%d”,&i);
printf(” Enter value of j ? “);
scanf(“%d”,&j);

printf(“\n Before swapping : i= %d, j= %d”,i,j);

/****first method using third variable*/
k=i;
i=j;
j=k;
printf(“\n After swapping (First method) : i= %d, j= %d\n”,i,j);

Leave a Reply

Your email address will not be published. Required fields are marked *