answersLogoWhite

0

#include<iostream>

void swap(int* x, int* x){

(*x)^=(*y)^=(*x)^=(*y);

}

int main()

{

int a, b;

a=10;

b=20;

std::cout<<"Before swap: a="<<a<<", b="<<b<<std::endl;

swap(&a,&b);

std::cout<<"After swap: a="<<a<<", b="<<b<<std::endl;

return(0);

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


How do you write a program in C plus plus plus plus How do you write a program in C to swap two variables without using the third oneo swap two variables without using the third one?

To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;


Write a c program for matrix addition using function?

#include&lt;


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

a=a^b; b=a^b; a=a^b;


How do you write a program in Perl to swap two variables without using the third one?

Use list assignment i.e. for two variables $a, $b: ($a,$b) = ($b,$a)


Write a program to calculate the area of a cylinder using a function?

give an example of calculation of mathematics


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


Can you write a program without using any semicolon inside the main function?

not possible dude


How do you write BASIC program to accept variables?

dim a input a


How do you write a c program to find area of rectangle using function?

There will be a function in it like this: double RectangleArea (double a, double b) { return a*b; }


Where do we write main function in a c program?

Into the source program.


How do you write a program using function that counts the number of vowels in a string in java language?

Use text-editor notepad++