hi all,
I seem to be running into the same problem over and over again.
To make a long story short, I am trying to make a part of the program display usd into euros and vice-verse. I am having trouble again with that part which has to do with the function call.
On the main function I use a scanf to take input from the user and pass that to the formal parameter 'currency' currency then is used to compute the exchange amount with a rate rate1 for euros and rate2 for usd. Then I assign the product of rate1, rate2 and currency to a variables change1 and change2. when I want to display the exchange in euros I use one and when I want to display the exchange in dollars I use the other.
However, instead of getting the exchange in the desired currency I get the input I introduced but not the conversion. I paste the code below. Thnx / bluetxxth
Code:
/*
* File: main.c
* Author: buetxxth
*
* Created on October 6, 2010, 1:31 PM
*/
#include <stdio.h>
#include <stdlib.h>
#define RATE 1.3 // the exchange rate
void change_chooser(double currency, double change1, double change2) {
double rate1 = 1 / RATE, // euro conversion rate
rate2 = RATE; // usd conversion rate this is 1.3
change1 = currency * rate1; // for usd to euros
change2 = currency * rate2; // for euros to usd //
}
int main(void) {
int option;
double chge1,
chge2,
curr; // to be copied to the forma parameter
printf("Choose option: (1-2) ");
scanf("%d", &option);
if (option == 1) {
printf("\n Desired Exchange in EUR\n\n"); // prints the choice selected
scanf("%lf", &curr); //this gets copied in te formal parameter currency
change_chooser(curr, chge1, chge2);
printf("%f EUR cost %f USD \n", curr, chge2); // prints output of choice selected in usd
} else if (option == 2) {
printf("\n Desired Exchange in USD\n\n"); // prints the choice selected
scanf("%lf", &curr); //this gets copied in te formal parameter currency
change_chooser(curr, chge1, chge2);
printf("%f USD cost %f EUR \n\n", curr, chge1); // prints output of choice selected in usd
}
return (0);
}