Question
What is the purpose of the #define directive in
programming languages like C and C++?Solution
The #define directive in C and C++ is a preprocessor command used to define macros. Macros can be constants or code snippets that are substituted into the program wherever they are referenced. For example, #define PI 3.14 defines a constant named PI with the value 3.14 . Similarly, #define SQUARE(x) ((x) * (x)) defines a macro for computing the square of a number. This directive helps in making the code more readable, manageable, and easier to maintain by avoiding the repetition of constants and code fragments. It operates at the preprocessing stage before the actual compilation of the code begins.
A question is given, followed by two statements numbered (I) and (II). You have to decide whether the data provided in the statements is sufficient to ...
How many female members are there in family of ten members?
I. Q is only son of H, who is son-in-law of A. S is only daughter of D. L is sister...
What is the code for ‘auto’ in the code language in which ‘giant segment the spot’ is written as ‘sag map pap rap’?<...
Seven persons Priyanka, Malti, Ruhi, Shivi, Teena, Unnati and Vipin were born on the same date of seven different years viz. 1998, 1999, 2000, 2001, 20...
Among six people P, Q, R, S, T and U, each having a different marks which is 12,17,23,25,26 and 29 (marks are arranged in decreasing order from left to...
In a certain code language which of the following is the code for “trunk”?
Statements:
I. “trunk call given” is coded as “ck g...
Is G grandfather of U?
I. E is mother of U and wife of B, who is only son of G.
II. U is only daughter of E, who is wife of B, who is...
F is in which direction with respect to E?
I. B is to the east of C, who is to the south of D. E is to the southwest of D and F is to the east of...
There are seven members in a family, four males and four females. A is wife of C. C has two sons D and B. Z is the mother of X. How is X related to C? ...
Statements: M > N, M > P, O = N
Conclusions: I. P > M II. O < M
...