The Currency Converter is a command-line utility written in C that allows users to convert amounts between different currencies. The tool supports a broad range of currencies and provides an easy-to-use interface for real-time currency conversion. The program uses exchange rates relative to USD, making it a versatile tool for various currency conversion needs.
- Multi-Currency Support: Convert between a wide range of currencies.
- Dynamic Currency Input: Enter currency codes and amounts dynamically.
- Error Handling: Handles invalid currency codes and amounts gracefully.
- Customizable Exchange Rates: Easily update exchange rates in the source code.
- Simple Interface: User-friendly command-line interface.
The Currency Converter supports the following currencies:
- USD: United States Dollar
- EUR: Euro
- JPY: Japanese Yen
- GBP: British Pound Sterling
- AUD: Australian Dollar
- CAD: Canadian Dollar
- CHF: Swiss Franc
- CNY: Chinese Yuan
- SEK: Swedish Krona
- NZD: New Zealand Dollar
- MXN: Mexican Peso
- SGD: Singapore Dollar
- HKD: Hong Kong Dollar
- NOK: Norwegian Krone
- KRW: South Korean Won
- TRY: Turkish Lira
- RUB: Russian Ruble
- INR: Indian Rupee
- BRL: Brazilian Real
- ZAR: South African Rand
- BDT: Bangladeshi Taka
- PKR: Pakistani Rupee
- THB: Thai Baht
- MYR: Malaysian Ringgit
- IDR: Indonesian Rupiah
- SAR: Saudi Riyal
- AED: United Arab Emirates Dirham
- CLP: Chilean Peso
- COP: Colombian Peso
- PEN: Peruvian Nuevo Sol
- DZD: Algerian Dinar
- EGP: Egyptian Pound
- MAD: Moroccan Dirham
- KWD: Kuwaiti Dinar
- BHD: Bahraini Dinar
- JOD: Jordanian Dinar
- OMR: Omani Rial
- LKR: Sri Lankan Rupee
- VND: Vietnamese Dong
- HUF: Hungarian Forint
- CZK: Czech Koruna
- PLN: Polish Zloty
- RON: Romanian Leu
- HRK: Croatian Kuna
- ISK: Icelandic Króna
- DOP: Dominican Peso
- NAD: Namibian Dollar
- MUR: Mauritian Rupee
- BMD: Bermudian Dollar
-
User Input:
- The user provides the source currency code (e.g., USD).
- The user provides the target currency code (e.g., EUR).
- The user enters the amount to convert.
-
Currency Lookup:
- The program retrieves exchange rates for the specified currencies.
- The amount is converted to USD using the source currency's exchange rate.
-
Conversion:
- The amount in USD is then converted to the target currency using its exchange rate.
-
Output:
- The program displays the converted amount in the target currency.
- C Compiler: Ensure you have a C compiler installed, such as
gcc
.
To compile the program, navigate to the directory containing currency_converter.c
and use the following command:
git clone https://github.com/mdriyadkhan585/Currency-Converter-C
cd Currency-Converter-C
gcc -o currency_converter currency_converter.c
This will generate an executable file named currency_converter
.
Execute the compiled binary with:
./currency_converter
- Enter the Source Currency Code: Type the 3-letter currency code of the source currency (e.g.,
USD
). - Enter the Target Currency Code: Type the 3-letter currency code of the target currency (e.g.,
EUR
). - Enter the Amount: Provide the amount to convert in the source currency.
The program will display the converted amount in the target currency.
./currency_converter
Enter the source currency code (e.g., USD): USD
Enter the target currency code (e.g., EUR): EUR
Enter amount to convert: 100
Converted amount: 93.00 EUR
This example converts 100 USD to EUR, displaying 93.00 EUR.
To update exchange rates, modify the currencies
array in currency_converter.c
with the latest rates. Ensure that each currency's rate is updated relative to USD.
- Add the currency code, full name, and exchange rate to the
currencies
array. - Ensure that the new currency code follows the 3-letter format and update the rates accordingly.
The program handles:
- Invalid Currency Codes: If an invalid currency code is entered, the program will display an error message.
- Invalid Amounts: Non-numeric or negative amounts will trigger an error message.
Contributions to improve the Currency Converter are welcome. You can:
- Submit pull requests to add features or fix bugs.
- Open issues for reporting bugs or requesting new features.
For questions or support, please contact mdriyadkhan585@gmail.com.