wat are the two methods for swapping two numbers without
using temp variable??

Answers were Sorted based on User's Feedback



wat are the two methods for swapping two numbers without using temp variable??..

Answer / shrikantauti

i dont know the methods but can give the code to swap values without temporary variable.
a b
a=a+b
b=a-b
a=a-b

Is This Answer Correct ?    6 Yes 0 No

wat are the two methods for swapping two numbers without using temp variable??..

Answer / abhishek karnani

int a=10,b=5;

a=a+b-(b=a);

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More C Interview Questions

Why we use void main in c?

0 Answers  


What is hashing in c?

0 Answers  


How to add two numbers without using arithmetic operators?

18 Answers   College School Exams Tests, e track, Infosys, Pan Parag, Sapient, TCS,


What are Macros? What are its advantages and disadvantages?

0 Answers   TCS,


What is a function simple definition?

0 Answers  






What is extern variable in c with example?

0 Answers  


int i=10; printf("%d %d %d", i, i=20, i);

0 Answers  


disadvantages of realloc ?

1 Answers   HCL,


What is main function in c?

0 Answers  


what are the languages used in c#?

3 Answers   Infosys,


where do we use volatile keyword?

1 Answers  


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

0 Answers   Infosys,


Categories