answersLogoWhite

0

Ellipses (...) used to emulate indentation... swap(int *a, int *b) {

... int temp;

... temp = *a;

... *a = *b;

... *b = temp;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

C program to swapping two numbers using call by value method?

You have to pass the address of the variables.void swap (int *pa, int *pb){...}


How to swap two numbers by call by reference in c plus plus?

void swap(int& a, int& b ) { a^=b^=a^=b; }


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 programme for substraction of two numbers in c language?

substracion of any two number program in c


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


What is program in c to swap entered two numbers without using third variable?

The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include<stdio.h> main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&a); printf("Enter b:"); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\n After swapping without using third variable"); printf("\na=%d\nb=%d",a,b); }


How do you swap two numbers with bitwise operator in c plus plus?

// Note: ^ is the XOR operator a = a ^ b b = b ^ a a = a ^ b


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 Swap two numbers using bitwise operator C?

//lets assume a = 10; b = 20; a = a^b; b = a^b; a = a^b;


How do you swap two numbers in c plus plus?

void swap(int &x, int &y) { x ^= y ^= x; } - or - void swap(int &x, int &y) { int t = x; x = y; y = t; }


Write a c program to find the largest and second largest number out of 3 numbers?

// return the larger of any 2 numbers int larger (int a, int b) { return a>b?a:b; } // return the largest of any 3 numbers int largest (int a, int b, int c) { return larger (larger (a, b), c)); } // return the middle value of any 3 numbers int middle (int a, int b, int c) { if (a>b) a^=b^=a^=b; // swap a and b (b is now the larger of the two) if (b>c) b^=c^=b^=c; // swap b and c (c is now the largest of all three) return larger (a, b); // return the larger of a and b }


Write a program to add two numbers using oop?

#include<iostream.h> #include<conio.h> void main() { int a, b, c; clrscr(); cout<<"enter the two numbers"; cin>>a; cin>b; c=a+b; cout<<"Addition of two numbers="<<c; getch(); }