Javatpoint Logo
Javatpoint Logo

Currency Converter in C++

Conversion of currencies is a difficulty that everyone faces. In the course of our regular activities, we must exchange currencies. Therefore, if someone wants to create a C++ application to convert currencies, this program is the greatest resource to use.

If you have experience with programming, you have probably created the currency conversion software in C, Python, Java, and other languages.

But if you're just starting off, stick around and you'll learn how to make a C++ currency converter.

Currency to Convert

We will exchange the dollars for British Pounds, French Francs, German Dutch Schillings, Japanese Yen, Indian Rupees, and French Francs. This software is a perfect answer to the textbook question, which is also included in various text books.

Prerequisites: Basic mathematical conversions of currency, variables in C++, Visual Studio.

Program Breakdown

We will going to include iostream library which is present in C++ to our program which is to convert the currency. A namespace is a declarative area that gives the names of the types, functions, variables, etc. within of it a scope.

Here, we have declared a float type variable dollar Due to its speed and narrower range than the double type, float has historically been preferred when working with hundreds or millions of floating-point values.

In the above peace of pseudo code, we have declared various float variables like bp stands for British pound and dividing 1 by 1.487 gives the basic conversion, frnc stands for French Francs and dividing 1 by 0.172 gives the basic conversion, deutschmark stands for German Dutch Schillings and dividing 1 by 0.584 gives the basic conversion, yen stands for Japanese Yen and dividing 1 by 0.00955 gives the basic conversion, ind stand for Indian Rupees and dividing 1 by 0.013 gives the basic conversion.

Here, these lines states that we are asking user to enter the dollars for conversion which gets stored in float type variable dollar.

To get the converted currency value we will multiply our float variables basic conversion values with the dollar amount entered by the user. Example is shown above.

Program of Above Explanation

Output:

When this program is executed, the user will communicate with it in the ways listed below to address his issues. The overall scenario is shown below.

pp -o curr } ; if ( $ ? ) { . \ currency } Enter the Dollars for Conversion: 10 Indian Rupees : 769.231 British Pounds : 6.72495 French franc : 58.1395 German Deutschmark : 17.1233 Japanese Yen : 1047.12 .......................... Process executed in 2.14 seconds Press any key to continue. PS C : \ Users \ user \ OneDrive \ Desktop \ vscode \.vscode >





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA