c-plus-plus
  1. c-plus-plus-currency-converter

Currency Converter Program in C++

A currency converter program in C++ converts one currency to another based on the exchange rate. Here's an example program that converts US dollars to Indian rupees.

Syntax

#include <iostream>
using namespace std;

int main() {
    float usd, inr, rate;

    cout << "Enter USD amount: ";
    cin >> usd;

    cout << "Enter exchange rate (1 USD to INR): ";
    cin >> rate;

    inr = usd * rate;

    cout << "INR amount: " << inr << endl;

    return 0;
}

Example

Enter USD amount: 50
Enter exchange rate (1 USD to INR): 73.44
INR amount: 3672

Explanation

In the above program, we first declare three variables, usd, inr, and rate. We then use the cout statement to ask the user to input the amount in USD and the exchange rate. We use the cin statement to get input from the user.

We then calculate the INR amount by multiplying the USD amount with the exchange rate. Finally, we use the cout statement to display the INR amount.

Use

A currency converter program can be used to convert one currency to another based on the exchange rate. This can be helpful for people who need to travel to another country or for businesses that deal with international transactions.

Important Points

  • A currency converter program takes in a currency amount and exchange rate as inputs and converts it to another currency.
  • The formula to convert currency is: converted_amount = amount * exchange_rate
  • Currency converters are useful for people who need to travel to another country or for businesses that deal with international transactions.

Summary

In summary, a currency converter program in C++ converts one currency to another based on the exchange rate. This can be helpful for people who need to travel to another country or for businesses that deal with international transactions. The program uses a simple formula to convert currency and displays the result to the user.

Published on: