Thread: i have a problem pls help!!!

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    i have a problem pls help!!!

    pls help i wrte a fuction that finds curency exchnages between turkish lira dolar and mark
    my code is :#include <stdio.h>
    #include <conio.h>

    double result;
    char fc,tc,value;
    double amount;

    float currency(char from_currency,char to_currency,double amount) {

    switch(from_currency) {
    case 't':
    switch(to_currency) {
    case 'd':
    result=amount/550000.0;
    value='D';
    break;
    case '$':
    result=amount/1345000.0;
    value='$';
    break;
    } //end of nested switch_1
    break; //break of case't'
    case 'd':
    switch(to_currency) {
    case 't':
    result=550000.0*amount;
    value='TL';
    break;
    case '$':
    result=550000*amount/1345000.0;
    value='$';
    break;
    } //end of nested switch_2
    break; //brak of case 'd'
    case '$':
    switch(to_currency) {
    case 't':
    result=1345000.0*amount;
    value='TL';
    break;
    case 'd':
    result=1345000*amount/550000.0;
    value='D';
    break;
    } //end of nested switch_3
    break; //break of case'$'
    } // end of main switch()
    return result;

    } // end of function

    void menu() {

    clrscr();
    printf("enter from_currency to_currency and amount of money\n");
    printf("for turkish lira use (t) for dolar use($) for mark use(d)\n");
    scanf("%c %c %l",&fc,&tc,&amount);
    } //end of menu


    void main() {
    menu();
    printf("\nresulting amount is %f %c",currency(fc,tc,amount),value);
    getch();
    } //end of main();

    when i enter $ for dolar d for mark and amount of dolar
    result is 0.0000 and after the result it should give the value of money($,tl,d) but it doesnt
    pls help what is the problem???
    Last edited by condorx; 04-09-2002 at 09:57 AM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >scanf("%c %c %l",&fc,&tc,&amount);
    You're not reading the amount correctly, try this and see how it works:
    scanf("%c %c %lf",&fc,&tc,&amount);

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    void main() really should be int main()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  2. Words and lines count problem
    By emo in forum C Programming
    Replies: 1
    Last Post: 07-12-2005, 03:36 PM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. Spot the problem..a test question, pls help!
    By Unregistered in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2002, 01:40 AM