Basic Macro Usage
Create a macro PI to hold the value of pi in a header file constants.h. Use this macro in a main.cpp file to calculate the area of a circle.
Hint
Remember that the formula for the area of a circle is Area = PI * radius * radius.
Answer
constants.h
#pragma once
#define PI 3.14159
main.cpp
#include <iostream>
#include "constants.h"
int main() {
double radius;
std::cout << "Enter the radius of the circle: ";
std::cin >> radius;
double area = PI * radius * radius;
std::cout << "The area of the circle is: " << area << std::endl;
return 0;
}