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

 
 
 

Contributors

Languages