All submissions

Square with Macro and Inline Function

#include <iostream>
using namespace std;

#define SQUARE(x) (x*x)

// NO NEED TO USE inline COMPILER CAN FIGURE IT OUT
inline int square(int x) {
   return x * x;
}

int main() {
   int n;
   cin >> n;
   // your code here: declare variables a and b, initialize with n
   int a{n}, b{n};
   // your code here: call macro and inline function using ++a and ++b
   // THIS WILL NOT WORK AS EXPECTED DUE TO SIDE EFFECTS
   cout << "Macro Square: " << SQUARE(++a) << "\n";
   // your code here: print results
   cout << "Inline Square: " << square(++b) << "\n";


   return 0;
}
Loading...

Input

5

Expected Output

Macro Square: 49 Inline Square: 36