๐น What is C++?
๐ข C++ is a powerful, fast, and flexible programming language widely used in:
- System software (e.g. operating systems)
- Game development
- Desktop applications
- Embedded systems
It is based on the C language, but with added support for object-oriented programming.
๐ ๏ธ Basic Structure of a C++ Program
Letโs start with the most basic program โ printing โHello, World!โ:
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
๐งฉ Code Explanation
Part | Meaning |
---|---|
#include <iostream> |
Includes the input/output library (cin , cout , etc.) |
using namespace std; |
Allows writing cout instead of std::cout
|
int main() |
Entry point of every C++ program |
cout << "..." << endl; |
Prints text to the console (endl adds a newline) |
return 0; |
Ends the program and returns 0 to the operating system (success signal) |
โ Output:
Hello, World!
๐ง Important Notes:
- Every C++ program starts from
main()
- Statements must end with a semicolon
;
-
cout
is used to output text to the screen
๐ Coming Up Next:
- Variables and Data Types (
int
,string
,float
, etc.) - Conditional Statements (
if
,else
) - Loops (
for
,while
) - Functions
- Introduction to OOP (Object-Oriented Programming)
Top comments (0)