Preprocessor
- What is the other name of the macro?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
When the compiler encounters a previously defined macro, it will take the result from that execution itself.
- What is the output of this program?
#include
using namespace std;
#define Maximum 100
int main()
{
int n;
num = ++Maximum;
cout << n;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Macro Preprocessor only replaces occurance of macro symbol with macro symbol value, So we can’t increment the value.
Compilation ErrorIn 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'
- What is the output of this program?
#include
using namespace std;
#define Function(id) cout << "The value of " #id " is "<int main()
{
int Num = 100;
Function(Num);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
In this program, we are just printing the declared values and it's id.
- What is the output of this program?
#include
using namespace std;
#define funOfSquare(num) num * num
int main()
{
int num;
cout << funOfSquare(num + 12);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, as we have not initialize the variable num, we will get a output of ending digit of 12.
- What is the output of this program?
#include
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;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, we are using the macros to print the information about the file.