C Programming - C Preprocessor - Discussion

Discussion Forum : C Preprocessor - Point Out Correct Statements (Q.No. 2)
2.
Which of the following are correctly formed #define statements in C?
#define CUBE (X) (X*X*X);
#define CUBE(x) (X*X*X)
#define CUBE(X)(X*X*X)
#define CUBE(X) {X*X*X}
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
31 comments Page 2 of 4.

Singh said:   1 decade ago
Option A will not be complile as between CUBE and (X) their is space
and their is no provision for double define value without \.

Eededdasd said:   9 years ago
Depends on the usage in the main method. All are correct except for B which makes no sense as the lower case is used.

Suhas said:   1 decade ago
Semi colon does not matter in macros.
It depends on compiler you are using like Turbo C (windows) and GCC in linux.

Rajesh.T.K. said:   1 decade ago
In GCC compiler, semicolon and space doesn't matter. But what happens with Turbo C compiler? can anyone explain me?

Kamal said:   1 decade ago
How could option C be correct? There is no space between CUBE(X) and (X*X*X). Please someone explain it.

Anshul said:   9 years ago
How could option C be correct? There is no space between CUBE(X) and (X*X*X). Please someone explain it.

:-) said:   1 decade ago
It is working Properly...

#define CUBE(X) (X*X*X)
#define CUBE(X) (X*X*X);
#define CUBE(X)(X*X*X)

Ketan said:   1 decade ago
After the #define their is spac important for defining process and than no semicolon after that.

Annanya said:   1 decade ago
Space is must in preprocessor declaration then how came the answer c? can anybody explains?

Anand kushwaha said:   1 decade ago
A and B are not work because a option is semicolon and option B gives the small latter x.


Post your comments here:

Your comments will be displayed after verification.