I am new to C and I am having trouble with a basic program that converts dollars to euros. When I print the final output both the dollar and euro amount is "0.00". Here is my code:
#include<stdio.h>
main()
{
float usd = 0.00;
float euro = 0.00;
const float conversion = 0.75;
printf("Please enter the amount of USD you want to convert to Euros: ");
scanf("%f", &usd);
euro = (usd * conversion);
printf("\n%.2f USD equals %.2f Euros.", &usd, &euro);
getch();
return 0;
}
Thanks in advance
Change the printf line to this:
printf("\n%.2f USD equals %.2f Euros.", usd, euro);
You are passing the addresses of usd and euro rather than the values themselves.
printf("\n%.2f USD equals %.2f Euros.", usd, euro);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With