1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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,276
    Likes Received:
    364
    Trophy Points:
    83
    3+2*3+2 is what you are getting when you expand the macro
     

Share This Page