VOOZH about

URL: https://www.geeksforgeeks.org/c/output-of-the-program-use-macros-carefully/

⇱ Output of the Program | Use Macros Carefully! - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of the Program | Use Macros Carefully!

Last Updated : 21 Jun, 2022

Predict the output of the below program  


Output
36

Explanation: Preprocessor replaces square(6) by 6*6 and the expression becomes x = 36/6*6 and value of x is calculated as 36. If we want correct behavior from macro square(x), we should declare it as #define square(x) ((x)*(x)) /* Note that the expression (x*x) will also fail for square(6-2) */

Comment
Article Tags: