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

how many keywords are present in "c"?

18 Answers   Assurgent, Cynosure Software, IBM,


what is dynamic polymorphism?

2 Answers   Satyam,


a characteristic of a multiprogramming is? a.simultaneous exe of pgm instr 4m 2 appli b.concurrent processing of 2 r more prgms c.multiple cpu s d.all the abov

0 Answers   TCS,


i want to open a helkp file that is txt file on link buttons click

1 Answers  


what is delegats ?

4 Answers  






What is the requirement in MIMD ?

1 Answers   Honeywell,


What is meant byStatic Variable ?

7 Answers   Mascot,


what is the difference between an application and service??? i mean service which runs as in services.msc.

2 Answers  


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

0 Answers  


How to update a data for the views in the relational data base schema

1 Answers   TCS,


how CLR identify vb file?

0 Answers   Tech Mahindra,


3. . Explain the Cache memory? What is the advantage of a processor having more cache memory?

1 Answers  


Categories