Home / CSE MCQs / C++ - MCQs :: Macros - C++

CSE MCQs :: C++ - MCQs

  1. which keyword is used to define the macros in c++?
  2. A.
    macro
    B.
    define
    C.
    #define
    D.
    none of the mentioned

  3. Which symbol is used to declare the preprocessor directives?
  4. A.
    #
    B.
    $
    C.
    *
    D.
    ^

  5. How many types of macros are there in c++?
  6. A.
    1
    B.
    2
    C.
    3
    D.
    4

  7. What is the mandatory preprosessor directive for c++?
  8. A.
    #define
    B.
    #include
    C.
    #undef
    D.
    none of the mentioned

  9.  What is the output of this program?

    #include < iostream >

    using namespace std;

    #define MIN(a,b) (((a)<(b)) ? a : b)

    int main ()

    {

    float i, j;

    i = 100.1;

    j = 100.01;

    cout << "The minimum is "  << MIN(i, j) << endl;

    return 0;

    }


  10. A.
    100.01
    B.
    100.1
    C.
    compile time error
    D.
    none of the mentioned

  11. What is the output of this program?

    #include < iostream >

    using namespace std;

    int main ()

    {

    cout << "Value of __LINE__ : " << __LINE__ << endl;

    cout << "Value of __FILE__ : " << __FILE__ << endl;

    cout << "Value of __DATE__ : " << __DATE__ << endl;

    cout << "Value of __TIME__ : " << __TIME__ << endl;

    return 0;

    }


  12. A.
    5
    B.
    Details about your file
    C.
    compile time error
    D.
    none of the mentioned

  13. What is the output of this program?

    #include < iostream >

    using namespace std;

    #define SquareOf(x) x * x

    int main()

    {

    int x;

    cout << SquareOf(x + 4);

    return 0;

    }



  14. A.
    16
    B.
    64
    C.
    compile time error
    D.
    none of the mentioned

  15. What is the output of this program?

    #include < iostream >

    using namespace std;

    #define PR(id) cout << "The value of " #id " is "<

    int main()

    {

    int i = 10;

    PR(i);

    return 0;

    }

  16. A.
    10
    B.
    15
    C.
    20
    D.
    none of the mentioned

  17. What is the output of this program?

    #include < iostream >

    using namespace std;

    #define MAX 10

    int main()

    {

    int num;

    num = ++MAX;

    cout << num;

    return 0;

    }

  18. A.
    11
    B.
    10
    C.
    compile time error
    D.
    none of the mentioned

  19. What is the other name of the macro?
  20. A.
    scripted directive
    B.
    executed directive
    C.
    link directive
    D.
    none of the mentioned