swap two number wthout using third variable
Answers were Sorted based on User's Feedback
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 |
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 |
Answer / suyog
A very simple and cute answer...
Assign as follows
a=a+b-(b=a)
Is This Answer Correct ? | 6 Yes | 0 No |
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 |
What is the use of Differ interface check box in Ship confirm?
How to swap two String values without using a third variable?
what is the difference between a namespace and assembly ?
What are the other ways to create an object with out calling new keyword in java?
what is the use of check point
hi i m deepak my shedule for NIC pi is 17 Apr please contact me if anybody has interview on same day or give me some idea who have faced
What is a singleton linked list?
What is the difference between: x=a+b+c+d; and x=SUM(a,b,c,d);?sas
There is a room with 1000 light switches, numbered 1, 2, 3, 4, ... 1000, all turned off. Outside the room there are 1000 men, numbered man1, man2, ...man 1000 In order, each man walks into the room and changes the position of each switch that is a multiple of his number. That is: man1 flips every switch man2 flips switches 2, 4, 6, 8 ....1000 man3 flips switches 3, 6, 9, ..... 999 ..... Man 1000 flips switch 1000 After all 1000 men are done, how many switches are on?
73. How can you set the status and title for a modal dialog box? a) In the attributes of the corresponding screen. b) Before the corresp. call screen statement. c) In a PBO module of the corresponding screen. d) In the PAI module of the corresponding screen.
if heap sort contains n elements, no of comparsions required are
class A{ void me(){s.o.p("");} class B extends A{ void me() {s.o.p(" ");} class M{ A a=new B(); B b=new A(); a.me(); b.mne();} what is the output of this, how?
2 Answers Cosmos, HyTech Pro, WinSoft,