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 / vijayakumar kanagasabai

main()
{
int a=4;b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping: a=%d, b=%d",a,b);
}

Is This Answer Correct ?    11 Yes 1 No

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

Answer / saida

int a=4,b=6;
printf("Before swapping: a=%d, b=%d",a,b);
a=a^b;
b=a^b;
a=a^b;
printf("After swapping: a=%d, b=%d",a,b);
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Interview Questions

Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

0 Answers  


prog for 1st five prime numbers in 2^x - 1

0 Answers  


write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]

7 Answers   Calsoft,


What are the advantages of using macro in c language?

0 Answers  


/*program to calculate hra,da in salary if salary less than 10000 then hra15%,da13% otherwise hra20%,da18%/*

6 Answers  






Explain the use of bit fieild.

0 Answers  


Explain the priority queues?

0 Answers  


The C language terminator is a.semicolon b.colon c.period d.exclamation mark

6 Answers   TCS,


Explain how do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


What are examples of structures?

0 Answers  


Is file a keyword in c?

0 Answers  


#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


Categories