answersLogoWhite

0

#include<stdio.h>

void main()

{

int a,b;

printf("enter number 1\n");

scanf("%d",&a);

printf("enter number 2\n");

scanf("%d",&b);

printf("the swapped result is\n");

a=a^b;

b=a^b;

a=a^b;

printf("%d\n",a);

printf("%d\n",b);

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is the Algorithm for exchanging values of two variables?

There are three primary algorithms to exchange the values of two variables. Exchange with Temporary Variable temp = a; a = b; b = temp; Exchange Without Temporary Variable Using Exclusive Or a = a ^ b; b = b ^ a; a = a ^ b; Exchange Without Temporary Variable Using Arithmetic a = a + b; b = b - a; a = a - b;


How do you write a c program to swap the values of two variables in unix?

#include&lt;stdio.h&gt; void main() { int a=2,b=4; printf("Program for swapping two numbers "); printf("Numbers before swapping"); printf("a=%d and b=%d",a,b); a=((a+b)-(b=a)); printf("Numbers after swapping"); printf("a=%d and b=%d",a,b); getch(); }


What is the meaning of 'swapping' in computer architecture?

Swapping means to swap the values of two addresses in main memory.


What is swap in c?

swapping is nothing but interchanging the values of a given character for example : if a=5 , b=4 before swapping then it becomes a=4,b=5 after swapping


What is meant by swapping of variables?

It means that you swap the values of that variables EX: -==- before swapping :- Variable1 = 5; variable2 = 10; after swapping :- Variable1 = 10; variable2 = 5;


What is the purpose of swapping?

Swapping was an older form of memory management. It was moving from/to secondary storage a whole program at a time, in a scheme known as roll-in/roll-out. Now swapping is a fairly close synonym of paging.


How do you write a program swaping of 2 integer?

To swap two integers in a program, you can use a temporary variable. Here's a simple example in Python: a = 5 b = 10 temp = a a = b b = temp Alternatively, you can swap them without a temporary variable using tuple unpacking: a, b = b, a Both methods will effectively swap the values of a and b.


Give all the programs written in java regarding swapping of values?

// Swapping values of a and b int a = 1; int b = 50; int temp = a; // temp = 1 a = b; // a = 50 b = temp; // b = 1


How do you write a program in C to swap two variables using the third variable?

Consider the following declarations:int x = 0;int y = 1;In order to swap the values, we need to use a temporary variable:int t = x;x = y;y = t;However, it is possible to swap the values without using a third variable:x ^= y ^= x ^= y;


A program to swap values using pass by value?

#include&lt;conio.h&gt; main() { int a,b; scanf("%d%d",&amp;a,&amp;b); printf("Before swapping A= %d B=%d",a,b); swap(a,b); getch(); } void swap(int a,int b) { int c; c=a; a=b; b=c; printf("After swapping A= %d B=%d",a,b); }


Program designed to swap the values of two variables?

You'll need 3 variables for this, here's a pseudo code for swapping values of 2 variables.ALGORITHM SWAPvar1 = 10var2 = 20temp = 0temp = var1 "temp = 10"var1 = var2 "var1 = 20, originally 10"var2 = temp "var2 = 10, originally 20"END SWAP


Which programming component provides a temporary named storage location in computer memory that cannot change during program execution?

The programming component that provides a temporary named storage location in computer memory that cannot change during program execution is called a constant. Constants are used to hold fixed values that remain the same throughout the execution of a program. They enhance code readability and prevent accidental modification of critical values. Examples include numeric literals, string literals, or named constants defined using specific syntax in various programming languages.