can any one explain me plz that What is the difference between #define n 10 and const int n=10???
can any one explain me plz that What is the difference between #define n 10 and const int n=10???
const int n = 10; is a numerical constant stored as an integer value.
Code:const int n = 10; // the compiler sees this exactly as you wrote it if (n == 10) puts("n = 10");
#define n 10 works by text substitution... that is where it finds n it replaces it with 10...
Code:#define n 10 // how you wrote it if (n == 10) puts("n = 10"); // now the compiler sees it if (10 == 10) puts("n = 10");
thanks alot......