A+ A-

General Structure of a Simple C++ Program

[code type="CPP Code"]#include <iostream> using namespace std; int main() { cout << "This is a simple C++ program!" << endl; } [/code]

You can type the text into an editor and save it to a file named simple.cpp. The actual name of the file is irrelevant, but the name “simple” accurately describes the nature of this program. The extension .cpp is a common extension used for C++ source code. After creating this file with a text editor and compiling it, you can run the program. The program prints the message.



[code type="CPP Result"]This is a simple C++ program![/code]

vThe actual name of the file is irrelevant, but the name “simple” accurately describes the nature of this program. The extension .cpp is a common extension used for C++ source code. After creating this file with a text editor and compiling it, you can run the program. The program prints the message.