Skip to content

cankecilioglu/credit-card-validator-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’³ Credit Card Validator (C++)

A tiny, fast C++ console app that validates credit card numbers using the Luhn algorithm.
Type a card number, get VALID / INVALID with basic stats. No dependencies.


✨ Features

  • βœ… Luhn algorithm validation
  • πŸ”’ Digits-only and length checks (13–19)
  • 🧹 Simple, robust I/O handling
  • πŸ’» Works on macOS/Linux/Windows (console)

πŸ›  Requirements

  • C++17 or later
  • A C++ compiler (e.g., g++, clang++, or MSVC)
  • Terminal/Console

πŸš€ Build & Run

🐧 macOS / Linux

g++ -std=c++17 -O2 -Wall -Wextra -o credit-card-validator src/main.cpp
./credit-card-validator

πŸͺŸ Windows (MinGW)

g++ -std=c++17 -O2 -Wall -Wextra -o credit-card-validator.exe src/main.cpp
credit-card-validator.exe

βš™οΈ Using CMake (All Platforms) (optional)

mkdir build && cd build
cmake ..
cmake --build .
# Run
./credit-card-validator   # macOS / Linux
credit-card-validator.exe # Windows

πŸ§ͺ Example

Enter credit card number (no spaces): 4539578763621486

Card Number: 4539578763621486 Length: 16 digits Status: βœ… VALID

🧠 How It Works (Luhn in 10 seconds)

1.	Traverse the number from right to left.
2.	Double every second digit; if result > 9, subtract 9.
3.	Sum all digits.
4.	If sum % 10 == 0 β†’ VALID, else INVALID.

About

Credit Card Validator Program with Luhn Algorithm in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages