First C++ program
wi.wwgiftidea.com
here's an example of a simple "Hello, World!" program in C++:
#include <iostream> int main() { std::cout << "Hello, World!"; return 0; }
This program uses the iostream
library to print the message "Hello, World!" to the console. The int main()
function is the entry point of the program, and the return 0
statement indicates that the program has completed successfully.
To run this program, you would need to save it in a file with a .cpp
extension (e.g., hello.cpp
), compile it using a C++ compiler (such as g++
on Linux or macOS, or Visual C++ on Windows), and then run the resulting executable file (e.g., hello.exe
on Windows, or ./hello
on Linux or macOS).