Square with Macro and Inline Function

#include <iostream>
using namespace std;

#define SQUARE(x) (x*x)

inline int square(int x) {
   return (x * x);
}

int main() {
   int n;
   cin >> n;
   // declare variables a and b, initialize with n
   int a = n, b = n;
   // call macro and inline function using ++a and b++
   a = SQUARE(++a);
   b = square(++b);
   // print results
   cout << "Macro Square: " << a << endl;
   cout << "Inline Square: " << b << endl;

   return 0;
}
Upvote
Downvote
Loading...

Input

5

Expected Output

Macro Square: 49 Inline Square: 36