Concept Flow - Structure of a C++ program
Start
Include Headers
Namespace Declaration
Main Function Declaration
Statements inside main()
Return Statement
Program Ends
This flow shows the basic parts of a C++ program from start to finish.
#include <iostream> using namespace std; int main() { cout << "Hello!" << endl; return 0; }
| Step | Code Line | Action | Output | State |
|---|---|---|---|---|
| 1 | #include <iostream> | Include standard input/output library | iostream available | |
| 2 | using namespace std; | Use standard namespace to avoid std:: prefix | namespace std active | |
| 3 | int main() { | Start main function | main started | |
| 4 | cout << "Hello!" << endl; | Print 'Hello!' and move to new line | Hello! | output printed |
| 5 | return 0; | End main function with success code | program ends | |
| 6 | } | Close main function | main closed |
| Variable | Start | After Step 4 | Final |
|---|---|---|---|
| cout (output stream) | empty | "Hello!\n" printed | "Hello!\n" printed |
#include <iostream> // Include input/output library
using namespace std; // Use standard namespace
int main() { // Main function start
cout << "Hello!" << endl; // Print message
return 0; // End program successfully
}