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 1 of 4.

Chaitali said:   1 decade ago
Why not a or b?
Please explain...

Vishnu said:   1 decade ago
Both a and b will work.

Saritha said:   1 decade ago
A and be will not work because option a has semicolon and preprocessor doesn't have semicolon.

In option b the x is a lowercase argument and used as uppercase.

Aniruddha said:   1 decade ago
Hey nice observation @saritha.

Arjun said:   1 decade ago
Is it not necessary to have a space in C?

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.

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

Khalid said:   1 decade ago
Semicolon and spaces between (x)and (x*x*x) makes option A wrong

:-) 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)

S.Parthasarathy said:   1 decade ago
Option B is the correct one... In preprocessor we can use lower cases also to define a function.. It is not compulsory to use higher cases..)


Post your comments here:

Your comments will be displayed after verification.