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
printfline to this:You are passing the addresses of
usdandeurorather than the values themselves.