Macros in C - Basic question

1
2
#define A 5
#define TWICE_A (2*A) 


Can I use TWICE_A as above? Will the preprocessor directive manage to resolve it? I cannot compile right now, otherwise I could have checked myself. Thanks!
Works with the online compiler attached to this site.

http://cpp.sh/4f2

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#define A 5
#define TWICE_A (2*A) 
int main()
{
  int x = A;
  int y = TWICE_A;
  std::cout << "x = " << x << std::endl;
  std::cout << "y = " << y << std::endl;
}
x = 5
y = 10
Topic archived. No new replies allowed.