Tuesday 31 January 2012

Thinking win win and found a trick

Well, I am feeling like think win win as I made a blog for my class fellows so that they may get help of programming in such a way that they may read the algorithms of different programs from the blog. I spend 1 hour daily to write the algorithms of different programs just to help my class fellows. Sometime it feels me not so good that i am spending my precious time for my fellows but I know and believe that I have to do it because if I know something and can help others then i should do it rather then being a insincere and proud.
Well today i was doing my practice of java then i got a trick. Our instructor taught us swapping using a third empty variable but i found that it can be done without declaring third variable as if there are two variables a and b having values then
  1. a=a+b;
  2. b=a-b;
  3. a=a-b; 
it will swap the values of a and b.

No comments:

Post a Comment