Why is the output of 49/square(7) 49 in C?
I have a macro defined as #define square(rasna) rasna*rasna. When I use this macro in the expression 49/square(7), the output is 49. However, I expected the output to be 1. Why is this happening?
Here is the code:
#include <stdio.h>
#define square(rasna) rasna*rasna
int main()
{
int rasna;
rasna = 49/square(7);
printf("%d", rasna);
return 0;
}
I would appreciate it if someone could help me understand why the output is 49.
I defined a macro as #define square(rasna) rasna*rasna
. I expected the output of the expression 49/square(7)
to be 1, because 49 divided by 49 is 1. However, the output is actually 49.
Here is a table summarizing what I tried, what I expected to happen, and what actually happened:
Defined Macro | Expected Output 49/square(7) | Actual Output |
---|---|---|
square(rasna) rasna*rasna | 1 | 49 |