1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The macro functions

Discussion in 'C' started by shubhadajs, Jan 24, 2011.

  1. shubhadajs

    shubhadajs New Member

    Joined:
    Jan 19, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Dear all
    I have a doubt regarding the macro function.


    #define SQR(x) (x*x)
    main()
    {
    int a,b=3;
    a= SQR(b+2);
    printf("%d",a);
    }

    The above program gives output as 11.
    And if I pass SQR(b+3), it gives o/p 15.

    How?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    3+2*3+2 is what you are getting when you expand the macro
     

Share This Page