Hey all Basically, I am trying to get my head around data validation. I am very new to C, in fact I have only been doing it a few days. I am trying to make a simple currency converter that validates that the data is numerical. Alos, I would like the app to exit if the user enters exit (in upper or lower case) This is what I have so far Code: #include <stdio.h> #include <conio.h> int main() { float input; //for input float rate =1.89712; //for rate float result; //for output printf("Please enter the amount you want to convert in GBP. "); //Get users input scanf ("%f",&input); clrscr(); result = input * rate; //do some maths printf("£%.2f is equal to %.2f euros\n",input, result);//show output } it does what I want but as I said, I need it to check the user has entered correct data and if not, loop back so they can input again. Also, I need it to exit when the user enters enter. edit: oh yea, btw, I only want it to convert from one to another at the mo Thankyou!
You put Code: printf("Please enter the amount you want to convert in GBP. "); //Get users input scanf ("%f",&input); into a loop till you get if every input is correct. isdigit function will help you know if its a digit