Re: [algogeeks] C Macro

2012-10-31 Thread dCoder
Thats because you have swapped pointers and printing variables.

On Mon, Oct 29, 2012 at 11:22 PM, rahul sharma rahul23111...@gmail.comwrote:

 I have taken form book...i am writing exact code

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t;


 int main()
 {
 float a,x;
 a=20.0;
 x=30.0;
 float *p,*q;
 p=a,q=x;
 swap(p,q,float*);
 printf(%f %f,a,x);
 getchar();
 }

 o/p=20.000 30.000


 why not swapped???
 On Mon, Oct 29, 2012 at 11:01 PM, atul anand atul.87fri...@gmail.comwrote:

 if you think the your expanded version is incorrect.You are wrong ,
 because int * will hold pointer but you are not allocating address of
 x ..instead you are allocating x value as an address of x to *t.This
 wont work.
 so to make it work you need to save the address of x and y in temp
 pointers i.e

int *p.*q;
 p=x;
 q=y;
 int t;
 t=*p;
 *p=*q;
 *q=t;
 now you can convert it into macro.

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  @atul...mistakenly  i have put w at place of t in my last post...i wana
 say
 
 
 
  On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:
 
  Just replace your macro with its definition and you will understand.
 
  its not doing swapping of pointers...plz explain
 
 
 
  @dCode i expanded..but its fine...please tell
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
  int main
  int x=10,y=20;
  int *p,*q;
  swap(x,y,int*);
 
  int * t;
  t=x;
  x=y;
  y=t;
 
 
  There is int* at the end..there is som problem with my
  keyborad...:(.acc to me axpanded version is above..but not
 swapping
  two pointerssplz comment
 
 
 
 
  On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
  rahul23111...@gmail.comwrote:
 
  its now doing swapping of pointers...plz explain
 
 
  On Sun, Oct 28, 2012 at 8:08 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  it should swap
 
  On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
   Why the following code is not able to swap two macros???although it
   is
   easily swapping 2 variables
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
  
   int main
  
  
   int x=10,y=20;
   int *p,*q;
  
   swap(x,y,int);
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, 

Re: [algogeeks] C Macro

2012-10-30 Thread Vikram Pradhan
@rahul : dude it's working fine ...check your printf() statement you
are swapping the pointers and printing the original float values of a and x
it should be printf(%f%f,*p,*q);

or if you want to swap float values not the pointers then it should be
swap(a,x,float);
printf(%f%f,a,x);


On Mon, Oct 29, 2012 at 11:30 PM, atul anand atul.87fri...@gmail.comwrote:

 well they should not , if you see it closely  pointer p and q
 contain contain address of a and x.
 and swap() macro will swap value these pointers are holding i.e adress
 of a and xbut will it reflect address of a and x ???...NO
 so if you print the address p and q ...before and after the swap then
 you should see that after swap p will be holding address of x and
 q will be holding address of a..that it

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  I have taken form book...i am writing exact code
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t;
 
 
  int main()
  {
  float a,x;
  a=20.0;
  x=30.0;
  float *p,*q;
  p=a,q=x;
  swap(p,q,float*);
  printf(%f %f,a,x);
  getchar();
  }
 
  o/p=20.000 30.000
 
 
  why not swapped???
  On Mon, Oct 29, 2012 at 11:01 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  if you think the your expanded version is incorrect.You are wrong ,
  because int * will hold pointer but you are not allocating address of
  x ..instead you are allocating x value as an address of x to *t.This
  wont work.
  so to make it work you need to save the address of x and y in temp
  pointers i.e
 
 int *p.*q;
  p=x;
  q=y;
  int t;
  t=*p;
  *p=*q;
  *q=t;
  now you can convert it into macro.
 
  On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
   @atul...mistakenly  i have put w at place of t in my last post...i
 wana
  say
  
  
  
   On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com
 wrote:
  
   Just replace your macro with its definition and you will understand.
  
   its not doing swapping of pointers...plz explain
  
  
  
   @dCode i expanded..but its fine...please tell
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
   int main
   int x=10,y=20;
   int *p,*q;
   swap(x,y,int*);
  
   int * t;
   t=x;
   x=y;
   y=t;
  
  
   There is int* at the end..there is som problem with my
   keyborad...:(.acc to me axpanded version is above..but not
  swapping
   two pointerssplz comment
  
  
  
  
   On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
   rahul23111...@gmail.comwrote:
  
   its now doing swapping of pointers...plz explain
  
  
   On Sun, Oct 28, 2012 at 8:08 PM, atul anand
   atul.87fri...@gmail.comwrote:
  
   it should swap
  
   On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although
it
is
easily swapping 2 variables
   
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t
   
   
int main
   
   
int x=10,y=20;
int *p,*q;
   
swap(x,y,int);
   
--
You received this message because you are subscribed to the
 Google
   Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
   
   
  
   --
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
--
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
--
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm 

Re: [algogeeks] C Macro

2012-10-30 Thread rahul sharma
Yeah its working...actually it was written in book...and i did nt
compilemistake of author

On Tue, Oct 30, 2012 at 12:17 PM, Vikram Pradhan vpradha...@gmail.comwrote:

 @rahul : dude it's working fine ...check your printf() statement you
 are swapping the pointers and printing the original float values of a and x
 it should be printf(%f%f,*p,*q);

 or if you want to swap float values not the pointers then it should be
 swap(a,x,float);
 printf(%f%f,a,x);


 On Mon, Oct 29, 2012 at 11:30 PM, atul anand atul.87fri...@gmail.comwrote:

 well they should not , if you see it closely  pointer p and q
 contain contain address of a and x.
 and swap() macro will swap value these pointers are holding i.e adress
 of a and xbut will it reflect address of a and x ???...NO
 so if you print the address p and q ...before and after the swap then
 you should see that after swap p will be holding address of x and
 q will be holding address of a..that it

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  I have taken form book...i am writing exact code
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t;
 
 
  int main()
  {
  float a,x;
  a=20.0;
  x=30.0;
  float *p,*q;
  p=a,q=x;
  swap(p,q,float*);
  printf(%f %f,a,x);
  getchar();
  }
 
  o/p=20.000 30.000
 
 
  why not swapped???
  On Mon, Oct 29, 2012 at 11:01 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  if you think the your expanded version is incorrect.You are wrong ,
  because int * will hold pointer but you are not allocating address of
  x ..instead you are allocating x value as an address of x to *t.This
  wont work.
  so to make it work you need to save the address of x and y in temp
  pointers i.e
 
 int *p.*q;
  p=x;
  q=y;
  int t;
  t=*p;
  *p=*q;
  *q=t;
  now you can convert it into macro.
 
  On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
   @atul...mistakenly  i have put w at place of t in my last post...i
 wana
  say
  
  
  
   On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com
 wrote:
  
   Just replace your macro with its definition and you will understand.
  
   its not doing swapping of pointers...plz explain
  
  
  
   @dCode i expanded..but its fine...please tell
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
   int main
   int x=10,y=20;
   int *p,*q;
   swap(x,y,int*);
  
   int * t;
   t=x;
   x=y;
   y=t;
  
  
   There is int* at the end..there is som problem with my
   keyborad...:(.acc to me axpanded version is above..but not
  swapping
   two pointerssplz comment
  
  
  
  
   On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
   rahul23111...@gmail.comwrote:
  
   its now doing swapping of pointers...plz explain
  
  
   On Sun, Oct 28, 2012 at 8:08 PM, atul anand
   atul.87fri...@gmail.comwrote:
  
   it should swap
  
   On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although
it
is
easily swapping 2 variables
   
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t
   
   
int main
   
   
int x=10,y=20;
int *p,*q;
   
swap(x,y,int);
   
--
You received this message because you are subscribed to the
 Google
   Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
 .
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
   
   
  
   --
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
--
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
--
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For 

Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
@atul...mistakenly  i have put w at place of t in my last post...i wana say



On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:

 Just replace your macro with its definition and you will understand.

 its not doing swapping of pointers...plz explain



@dCode i expanded..but its fine...please tell

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t

 int main
 int x=10,y=20;
 int *p,*q;
 swap(x,y,int*);

int * t;
t=x;
x=y;
y=t;


There is int* at the end..there is som problem with my
keyborad...:(.acc to me axpanded version is above..but not swapping
two pointerssplz comment




 On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma rahul23111...@gmail.comwrote:

 its now doing swapping of pointers...plz explain


 On Sun, Oct 28, 2012 at 8:08 PM, atul anand atul.87fri...@gmail.comwrote:

 it should swap

 On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
  Why the following code is not able to swap two macros???although it is
  easily swapping 2 variables
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
 
  int main
 
 
  int x=10,y=20;
  int *p,*q;
 
  swap(x,y,int);
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
if you think the your expanded version is incorrect.You are wrong ,
because int * will hold pointer but you are not allocating address of
x ..instead you are allocating x value as an address of x to *t.This
wont work.
so to make it work you need to save the address of x and y in temp pointers i.e

   int *p.*q;
p=x;
q=y;
int t;
t=*p;
*p=*q;
*q=t;
now you can convert it into macro.

On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
 @atul...mistakenly  i have put w at place of t in my last post...i wana say



 On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:

 Just replace your macro with its definition and you will understand.

 its not doing swapping of pointers...plz explain



 @dCode i expanded..but its fine...please tell

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t

 int main
 int x=10,y=20;
 int *p,*q;
 swap(x,y,int*);

 int * t;
 t=x;
 x=y;
 y=t;


 There is int* at the end..there is som problem with my
 keyborad...:(.acc to me axpanded version is above..but not swapping
 two pointerssplz comment




 On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
 rahul23111...@gmail.comwrote:

 its now doing swapping of pointers...plz explain


 On Sun, Oct 28, 2012 at 8:08 PM, atul anand
 atul.87fri...@gmail.comwrote:

 it should swap

 On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
  Why the following code is not able to swap two macros???although it
  is
  easily swapping 2 variables
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
 
  int main
 
 
  int x=10,y=20;
  int *p,*q;
 
  swap(x,y,int);
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google
 Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
I have taken form book...i am writing exact code

#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t;


int main()
{
float a,x;
a=20.0;
x=30.0;
float *p,*q;
p=a,q=x;
swap(p,q,float*);
printf(%f %f,a,x);
getchar();
}

o/p=20.000 30.000


why not swapped???
On Mon, Oct 29, 2012 at 11:01 PM, atul anand atul.87fri...@gmail.comwrote:

 if you think the your expanded version is incorrect.You are wrong ,
 because int * will hold pointer but you are not allocating address of
 x ..instead you are allocating x value as an address of x to *t.This
 wont work.
 so to make it work you need to save the address of x and y in temp
 pointers i.e

int *p.*q;
 p=x;
 q=y;
 int t;
 t=*p;
 *p=*q;
 *q=t;
 now you can convert it into macro.

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  @atul...mistakenly  i have put w at place of t in my last post...i wana
 say
 
 
 
  On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:
 
  Just replace your macro with its definition and you will understand.
 
  its not doing swapping of pointers...plz explain
 
 
 
  @dCode i expanded..but its fine...please tell
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
  int main
  int x=10,y=20;
  int *p,*q;
  swap(x,y,int*);
 
  int * t;
  t=x;
  x=y;
  y=t;
 
 
  There is int* at the end..there is som problem with my
  keyborad...:(.acc to me axpanded version is above..but not
 swapping
  two pointerssplz comment
 
 
 
 
  On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
  rahul23111...@gmail.comwrote:
 
  its now doing swapping of pointers...plz explain
 
 
  On Sun, Oct 28, 2012 at 8:08 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  it should swap
 
  On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
   Why the following code is not able to swap two macros???although it
   is
   easily swapping 2 variables
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
  
   int main
  
  
   int x=10,y=20;
   int *p,*q;
  
   swap(x,y,int);
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
well they should not , if you see it closely  pointer p and q
contain contain address of a and x.
and swap() macro will swap value these pointers are holding i.e adress
of a and xbut will it reflect address of a and x ???...NO
so if you print the address p and q ...before and after the swap then
you should see that after swap p will be holding address of x and
q will be holding address of a..that it

On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
 I have taken form book...i am writing exact code

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t;


 int main()
 {
 float a,x;
 a=20.0;
 x=30.0;
 float *p,*q;
 p=a,q=x;
 swap(p,q,float*);
 printf(%f %f,a,x);
 getchar();
 }

 o/p=20.000 30.000


 why not swapped???
 On Mon, Oct 29, 2012 at 11:01 PM, atul anand
 atul.87fri...@gmail.comwrote:

 if you think the your expanded version is incorrect.You are wrong ,
 because int * will hold pointer but you are not allocating address of
 x ..instead you are allocating x value as an address of x to *t.This
 wont work.
 so to make it work you need to save the address of x and y in temp
 pointers i.e

int *p.*q;
 p=x;
 q=y;
 int t;
 t=*p;
 *p=*q;
 *q=t;
 now you can convert it into macro.

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  @atul...mistakenly  i have put w at place of t in my last post...i wana
 say
 
 
 
  On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:
 
  Just replace your macro with its definition and you will understand.
 
  its not doing swapping of pointers...plz explain
 
 
 
  @dCode i expanded..but its fine...please tell
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
  int main
  int x=10,y=20;
  int *p,*q;
  swap(x,y,int*);
 
  int * t;
  t=x;
  x=y;
  y=t;
 
 
  There is int* at the end..there is som problem with my
  keyborad...:(.acc to me axpanded version is above..but not
 swapping
  two pointerssplz comment
 
 
 
 
  On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
  rahul23111...@gmail.comwrote:
 
  its now doing swapping of pointers...plz explain
 
 
  On Sun, Oct 28, 2012 at 8:08 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  it should swap
 
  On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
   Why the following code is not able to swap two macros???although
   it
   is
   easily swapping 2 variables
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
  
   int main
  
  
   int x=10,y=20;
   int *p,*q;
  
   swap(x,y,int);
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
  --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
   --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this 

Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
it should swap

On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
 Why the following code is not able to swap two macros???although it is
 easily swapping 2 variables

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t


 int main


 int x=10,y=20;
 int *p,*q;

 swap(x,y,int);

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
didnt get you... first it was now working , now its working...!!!
 please write clearly about your doubts.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.