swap two number wthout using third variable

Answers were Sorted based on User's Feedback



swap two number wthout using third variable..

Answer / jvhariharan

void main()
{
int a=10,b=20;
a=a+b;
b=a-b;
a=a-b;
}

Is This Answer Correct ?    24 Yes 3 No

swap two number wthout using third variable..

Answer / ashutosh tiwari

void swap_num(int *a, int *b)
{
*a = *a+*b; *b = *a-*b; *a = *a-*b;
}
or
void swap_num(int *a,int *b)
{
*a = *a^*b; *b = *a^*b; *a = *a^*b;
}

Is This Answer Correct ?    8 Yes 0 No

swap two number wthout using third variable..

Answer / suyog

A very simple and cute answer...

Assign as follows

a=a+b-(b=a)

Is This Answer Correct ?    6 Yes 0 No

swap two number wthout using third variable..

Answer / abhay khare

void main()
{
int a,b,c
printf("two no are\n");
scanf("%d&n");
a=c;
b=a
c=b
getch;
}

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More Programming Languages AllOther Interview Questions

1.What is difference between symget and & in sas? 2.what is difference between callsymput and %let?

1 Answers   CitiGroup,


pleasew define carrier scope in abap (sap).

0 Answers  


how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnn 

0 Answers  


DIFFERENCE BETWEEN BINDING LANG AND BIND DIR WHEN USING IN SERVICE PGM

0 Answers   CTS,


What are events in smartforms?

0 Answers   Accenture,






can we retrieve only integer/String type columns from a table,if yes how?

0 Answers  


How to swap values between two variables without using a third variable?

24 Answers   HCL, TCS,


hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.

0 Answers  


Define distributed queries. can you explain me as soon as possible

0 Answers   HCL,


9.Difference between even and odd signals?explain with the diagram?

0 Answers  


What is diffrent between Method and and function in c#

0 Answers  


What is Negative testing?

0 Answers  


Categories