Question

//Question 1: Currency conversion // Write some code that first asks the user to type the...

//Question 1: Currency conversion
// Write some code that first asks the user to type the current
// conversion rate for 1 U.S. Dollar (USD) to 1 Euro. Next, in a while
// loop, ask users for an amount in USD, read it in, and convert it to
// Euro, printing as you go. Use 0 as a sentinel (i.e.: a signal to
// stop the loop).
// Here's a sample run:
// Whats the current conversion rate for 1 USD to 1 Euro:
// .85
// Enter an amount in USD:
// 10.0
// 10.0 in USD is equal to 8.5 Euro
// Enter an amount in USD:
// 2.0
// 2.0 in USD is equal to 1.7 Euro
// Enter an amount in USD:
// 0
// Quitting...
  
  

Homework Answers

Answer #1

#include<stdio.h>
#include<conio.h>
void main()
{
float usd=0.0,euro=0.0,convert=0.0;
printf("What is the current convertion rate for 1 USD to 1 Euro:");
scanf("%f",&euro);
while(1)
{
printf("\nEnter an amount in USD:");
scanf("%f",&usd); //acccept input from the user
if(usd==0) // when usd value equal to 0 it will execute if block
{
exit(0); //terminates the calling process immediately
}
convert=usd*euro; //convertion formula
printf("%.2f in USD is equal to %.2f Euro",usd,convert);
}
getch();
}

Output:

Please give positive rating.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT