Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. which keyword is used to define the macros in c++?
  1.    macro
  2.    define
  3.    #define
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> #define


#define


Question 2. Which symbol is used to declare the preprocessor directives?
  1.    #
  2.    $
  3.    *
  4.    ^
 Discuss Question
Answer: Option A. -> #


#


Question 3. How many types of macros are there in c++?
  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer: Option B. -> 2


There are two types of macros. They are object-like and function-like.


Question 4. What is the mandatory preprosessor directive for c++?
  1.    #define
  2.    #include
  3.    #undef
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> #include


For a c++ program to execute, we need #include.


Question 5.

 What is the output of this program?

#include < iostream >

using namespace std;

#define MIN(a,b) (((a)

  1.    100.01
  2.    100.1
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 100.01


In this program, we are getting the minimum number using conditional operator.


Question 6.

What is the output of this program?

#include < iostream >

using namespace std;

int main ()

{

cout

  1.    5
  2.    Details about your file
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> Details about your file


In this program, we are using the macros to print the information about the file.


Question 7.

What is the output of this program?

#include < iostream >

using namespace std;

#define SquareOf(x) x * x

int main()

{

int x;

cout

  1.    16
  2.    64
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer: Option D. -> none of the mentioned


In this program, as we haven't initiailzed the variable x, we will get a output of ending digit of 4.


Question 8.

What is the output of this program?

#include < iostream >

using namespace std;

#define PR(id) cout

  1.    10
  2.    15
  3.    20
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 10


In this program, we are just printing the declared values.


Question 9.

What is the output of this program?

#include < iostream >

using namespace std;

#define MAX 10

int main()

{

int num;

num = ++MAX;

cout

  1.    11
  2.    10
  3.    compile time error
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> compile time error


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


Question 10. What is the other name of the macro?
  1.    scripted directive
  2.    executed directive
  3.    link directive
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> scripted directive


When the compiler encounters a previously defined macro, it will take the result from that execution itself.


Latest Videos

Latest Test Papers