Hey guys., i wrote a little program to calculate the foreign exchange of canadian dollar to french frank. but when i validate an input(it has to be between 1 and a 1000), i get a problem even though it makes user to reenter the number, still the very first number enter is used. any suggestions would be greatly appreciated!!
cheers!

#include<stdio.h>

double GetAmount(void);
double AmountValidate(double amount);
double CalcAmount(double amount_c, double exchange_rate);
void PrintResults(double canadian_d, double french_f);

main()
{

	double amount_c; double amount_f;
	double exchange_rate=3.528582;
	
	amount_c=GetAmount();
	AmountValidate(amount_c);
	amount_f=CalcAmount(amount_c, exchange_rate);
	PrintResults(amount_c, amount_f);

}

double GetAmount(void)
{
	double amount;	
	
	printf("Hello, this program will convert CAD to French Franks\n");
	printf("The Exchange rate is 3.528582., Enter the amount in CAD:");
	scanf("%lf", &amount);
    return amount;
}


double AmountValidate(double amount_c)
{
	
	    while(amount_c < 1.0 || amount_c >1000.0)
		{
          printf("Invalid Entry, Must be between 1 and 1000, Please Re-Enter:");
		  scanf("%lf", &amount_c);
		}

    return amount_c;
}


double CalcAmount(double amount_c, double exchange_rate)
{

	double french_f;
	
	french_f=amount_c*exchange_rate;
	return french_f;
}

void PrintResults(double canadian_d, double french_f)
{
	printf("******* Foreign Exchange ********\n");
	printf("Canadian dollars: %.2lf\n", canadian_d);
	printf("French francs: %.2lf\n", french_f);
	printf("*********************************\n");
}

You don't reassign amount when you call AmountValidate from the main method.

amount_c=GetAmount();
amount_c=AmountValidate(amount_c);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.