C++ Fibonacci number example

How to Run C++ Program on Mac Terminal

Use g++ command to compile a C++ program and build the executable so that you can run the C++ program on the Mac terminal. Below is the syntax of g++ command:

g++ Syntax

g++ programname.cpp -o executablename


Suppose you have written a C++ program in a file named hellow.cpp. Then open the terminal window change the directory to the file location and execute the following g++ command:

g++ hellow.cpp -o hellow

The above first command will compile the hellow.cpp and build the executable hellow. The command in the second line above will run the C++ program hellow.

Related Tutorials:

Fibonacci Series in C++ (Recursion Example)

Written by Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.org and orclqa.com a question and answer forum for developers. You can connect with me on Facebook and Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *