21. Square of a Number

Back To All Submissions
Previous Submission
Next Submission
#include <iostream>
using namespace std;

#define SQUARE(x) ((x) * (x))   // macro
inline int square(int x) {      // inline function
    return x * x;
}

int main() {
    int n;
    cin >> n;
    cout << "Macro Square: " << SQUARE(n) << "\n";
    cout << "Inline Square: " << square(n) << "\n";
    return 0;
}
Was this helpful?
Upvote
Downvote