Home » C++ Programming » Preprocessor » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    #define Maximum 100
    int main()
    {
    int n;
    num = ++Maximum;
    cout << n;
    return 0;
    }
    1. 100
    2. Compilation Error
    3. Runtime Error
    4. Garbage value
    5. None of these
Correct Option: B

Macro Preprocessor only replaces occurance of macro symbol with macro symbol value, So we can’t increment the value.
Compilation Error

In function 'int main()':
7:9: error: 'num' was not declared in this scope
3:21: error: lvalue required as increment operand
7:17: note: in expansion of macro 'Maximum'



Your comments will be displayed only after manual approval.