Aarav
asked

Expert
Abhay Jajodia answered
Hi Aarav,
A macro is a text replacement done before compilation using #define. It does not create a real variable in memory.
#define PI 3.14
A variable is a real storage location in memory with a type, and its value can change while the program runs.
float pi = 3.14;
So the simple difference is: macros are replaced in the code, variables store values in memory.
If you have more questions, I am here to help 😊
C
This question was asked as part of the Learn C Programming course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer