I am just starting to learn the C programming language. I wrote this simple code that converts US dollars to euros. The only problem is that as soon as the USD input is entered, the program simply freezes. I use a while loop to ask the user if they want to repeat the operation, so I assume that the syntax of the code causes an eternal loop, but I'm not sure.
Here is my code:
#include<stdio.h>
#define conv 0.787033
int main(void)
{
float USD, EURO;
char cont = 'y';
while (cont == 'Y' || cont == 'y')
{
printf("Please enter the amount of United States ");
printf("Dollars you wish to convert to Euros\n");
scanf("%f\n", &USD);
EURO = USD * conv;
printf("%.2f dollars is %.2f Euros\n", USD, EURO);
printf("Do you wish to convert another dollar amount (Y/N)?\n");
scanf("%c\n", &cont);
}
return(0);
}
source
share