Your First C++ Program
Prerequisites: Installing a C++ compiler
Create a file named hello.cpp:
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
g++ -std=c++20 hello.cpp -o hello
./hello
std::cout ("character output") sends text to the console using
<<, in place of C's printf; std:: is a namespace prefix,
covered in its own lesson shortly.
Practice
Change the program to print your own name instead of "Hello, world!".
Show solution
#include <iostream>
int main() {
std::cout << "Ada" << std::endl;
return 0;
}