Write a C Program to swap two numbers without using third variable. - Pratik Ghelani

Pratik Ghelani

Breaking

Thursday, January 10, 2019

Write a C Program to swap two numbers without using third variable.

Program:-

#include <stdio.h>
void main()
{
  int a,b,c;
  printf("Enter two integers\n");
  scanf("%d%d", &a, &b);
  printf("Before Swapping\nA = %d\nB = %d\n", a,b);
  c = a;
  a = b;
  b = c;
  printf("After Swapping\nA = %d\nB = %d\n", a,b);

}
Output:-


No comments:

Post a Comment