Skip to content

Sayanti2003/Basic-cpp-programs

 
 

Repository files navigation

# 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
./example

To 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 *.o

How to contribute

Contributions are welcome! Suggested guidelines:

  1. Fork the repository and create a feature branch (e.g., feature/new-example).
  2. Add well-commented code and meaningful filenames.
  3. Include a brief comment or README at the top of new examples explaining purpose, input, and expected output.
  4. 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.

License

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.

Contact

Maintainer: @Sbiswas001


Happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%