Here is a simple example of a C++ program in a file named helloworld.cpp
.
// helloworld.cpp
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
Use the terminal command shown below to build and run the program. You should see the words Hello world!
printed in the terminal.
clang++ helloworld.cpp -o helloworld; ./helloworld
C++ Programs © 2025
Built with Genja by Gavin Wiggins