Sunday, 29 April 2012

Using Parametrized Macros in C++


#include <iostream>
#define SQUARE(x) ((x) * (x))

int main(  )
{
    int i; 

    i = 0;
    while (i < 5)
        std::cout << "x " << (i+1) << 
                " x squared is" << SQUARE(++i) << '\n';
    return (0);
}

No comments:

Post a Comment