C++ Basics

Write and run a first program.

C++
#include <iostream>
using namespace std;

int main() {
  cout << "Hello Programonic\n";
}
Output
Hello Programonic

Explanation

A C++ program begins in main. Include iostream to write to standard output with cout. The line using namespace std; lets you write cout instead of std::cout.

Explore the dry run
Guided walkthroughReady
1#include <iostream>
2using namespace std;
3
4int main() {
5 cout << "Hello Programonic\n";
6}

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Program execution enters main.—
—
Write the string and newline to standard output.—
Hello Programonic