google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program for swapping of two numbers without using third variable in c - 2nd puc computer science

Write a program for swapping of two numbers without using third variable in c

 Write a program for swapping of two numbers without using third variable in c. 

write a c program for interchanging of two numbers without using third variable

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b;

clrscr();

printf("Enter two numbers\n");

scanf("%d%d",&a,&b);

printf("Before interchanging a=%d and b=%d\n",a,b);

a=a+b;

b=a-b;

a=a-b;

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

getch();

}

Output:

Enter two numbers

5                                                                               

6                                                                             

Before interchanging a=5 and b=6                                               

After interchanging a=6 and b=5

Write a program for swapping of two numbers without using third variable in c  Write a program for swapping of two numbers without using third variable in c Reviewed by Vision Academy on December 07, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.