Sail E0 Webinar

MCQs

Total Questions : 9
Question 1.

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.


Question 2.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
#define MAX
4.
int main()
5.
{
6.
int num;
7.
num = ++MAX;
8.
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 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
#define SquareOf(x) x * x
4.
int main()
5.
{
6.
int x;
7.
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.
Output:
$ g++ mac1.cpp
$ a.out
75386824



Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
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.
Output:
$ g++ mac2.cpp
$ a.out
Value of __LINE__ : 5
Value of __FILE__ : mac1.cpp
Value of __DATE__ : Oct 10 2012
Value of __TIME__ : 22:24:37


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
#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.
Output:
$ g++ mac3.cpp
$ a.out
The minimum value is 100.01


Question 6.

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 7.

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

None.


Question 8.

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 9.

Which symbol is used to declare the preprocessor directives?


  1.    #
  2.    $
  3.    *
  4.    ^
 Discuss Question
Answer: Option A. -> #

None.


Latest Videos

Latest Test Papers