Q. What is the output?

Code:
#include <stdio.h>
#define SQUARE(x) x*x
int main() {
    printf("%d", SQUARE(3+1));
    return 0;
}
  • (A) 16
  • (B) 12
  • (C) 7
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 7
Explanation: SQUARE(3+1) expands to 3+1*3+1 = 3+3+1 = 7. Use parentheses in macro!
Explanation by: Mr. Dubey
SQUARE(3+1) expands to 3+1*3+1 = 3+3+1 = 7. Use parentheses in macro!

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
107
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
80%
Success Rate