• C

Currency conversion

Write a C program to do currency conversion. The program will display a title "Currency Conversion," ask the user to enter the amount in US dollars, and then convert it into 5 foreign currencies. The program will then output the names of five currencies and their equivalents to US dollars. Use the exchange rates below.

1 Swiss Franc = 0.6072 US dollars
1 British Pound = 1.4320 US Dollars
1 Japanese Yen = 0.0081 US DOLLARS
1 Canadian Dollar = 0.6556 US Dollars
1 Euro                 = 0.8923 US Dollars
Who is Participating?
ankuratvbConnect With a Mentor Commented:
Think what you have to do:

First,you need to get the dollar value from the user.Take a float.
float dollar;

Then,conversion requires multiplication with the values you have provided above.These are decimal values as well,so use float for them as well.
float euro=0.1234;//whatever your value,place here
//similarly for the other currencies as well.

Multiply the dollar with the conversion value and you have the converted value.

Use printf() to display the text and the converted value.
Sjef BosmanGroupware ConsultantCommented:
And your problem is... What's the code you have?

We're not allowed to do your homework,
either post your attempt at the code,or tell us specifically where you are stuck,
We'll be glad to help.

Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

shnhutsonAuthor Commented:
I am stuck after I include < stdio.h>. How do I define the different currencies.
Lets say you define euro as:
float euro=0.8923;

>The program will then output the names of five currencies and their equivalents to US >dollars.

1 USD=1/euro

Use printf() to print these values out for all the five currencies.
Sjef BosmanGroupware ConsultantCommented:
Now are you doing the homework for him/her after all. Writing the code would have been a lot faster, about 12 lines would be enough, wouldn't it?

ShnHutson: do you have a good book on C? I have a very old Kernighan & Ritchie "The C Programming Language", and you can find a similar program on page 8 already! (Celsius-Fahrenheit conversion)
shnhutsonAuthor Commented:
Thanks for the help, I don't have any books on C. Only the teacher's weekly notes. What you have posted helped me out the rut.
shnhutsonAuthor Commented:
I accepted it because I pieced together some of the comments that were made. I was running out of time.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.