compile and run cpp file on mac c++

Step 1: Open Terminal on your Mac Step 2: Navigate to the directory where your C++ file is located Step 3: Use the g++ compiler to compile the C++ file by running the command: g++ -o outputFileName inputFileName.cpp Step 4: Once the compilation is successful, run the executable file by entering: ./outputFileName