# Basic C++ Programs
A collection of small, well-commented C++ example programs intended for beginners and intermediate learners to study C++ syntax, core concepts, and standard library usage.
## Repository structure
Programs are organized by topic. Example categories you may find in this repo:
- Hello World and basic I/O
- Control flow (if/else, switch, loops)
- Functions and recursion
- Arrays, strings, and vectors
- Pointers, references, and dynamic memory
- Structs and classes (OOP basics)
- File I/O
- Standard Template Library (STL) examples
- Simple algorithms and problem-solving examples
Filenames and folders may vary — explore the repository to see each program and its accompanying comments.
## Requirements
- A C++ compiler supporting C++11 or later (g++, clang++, MSVC)
- Basic command-line experience
## Compile and run
To compile a single program (example.cpp) with g++:
```bash
# compile
g++ -std=c++11 -Wall -Wextra -O2 example.cpp -o example
# run
./exampleTo compile multiple files or build the whole repository, consider adding a Makefile or using a build system. Example Makefile rule:
# Simple Makefile example
SRC = $(wildcard *.cpp)
OBJ = $(SRC:.cpp=.o)
all: programs
programs: $(SRC)
g++ -std=c++11 -Wall -O2 $^ -o bin/programs
clean:
rm -f bin/programs *.oContributions are welcome! Suggested guidelines:
- Fork the repository and create a feature branch (e.g.,
feature/new-example). - Add well-commented code and meaningful filenames.
- Include a brief comment or README at the top of new examples explaining purpose, input, and expected output.
- Open a pull request describing the changes and why the example is useful.
When adding examples, prefer clear, minimal inputs and include sample runs in comments or a short text file.
This repository does not include a license file by default. If you want to add one, consider the MIT License. To apply MIT, add a LICENSE file with the standard text and update this section.
Maintainer: @Sbiswas001
Happy coding!