using define in cpp code example
Example 1: define in cpp
#include <iostream>
// macro definition
#define LIMIT 5
int main()
{
for (int i = 0; i < LIMIT; i++) {
std::cout << i << "\n";
}
return 0;
}
Example 2: #define in cpp
// The #define preprocessor directive creates symbolic constants
#include <iostream>
using namespace std;
#define CONSTANT 2.71828
int main () {
cout << "Declared constant: " << CONSTANT << endl;
return 0;
}