Skip to content
techsnow

Introduction

Your First Program

Syntax:

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, C++!" << endl;
    return 0;
}

Output

Hello, C++!
LineMeaning
#include <iostream>Brings in input/output tools like cout and cin.
using namespace std;Lets you write cout instead of std::cout.
int main()Where every C++ program starts.
cout << ... ;Prints to the screen. endl adds a new line.
return 0;Tells the system the program finished successfully.

Compile and run

g++ hello.cpp -o hello
./hello