Thread: how to do this currency conversion

  1. #1
    Registered User
    Join Date
    Feb 2010

    Unhappy how to do this currency conversion

    hello gents
    I am a beginner for the last 15 years as I do little bit of programming for a month and then give up on C-programming
    Here is my homework and is little frustrating for my ignorance and asking too..
    thanks in advance...
    I need to in this code below..
    If curr(currency) selection is if 0>curr<6 then printf("error: please enter between 1 to 5 for selection and then proceed with calculation of currency conversion\n")

    How do I do this as when I enter 6(not acceptable) it proceeds to switch/case
    but it should only proceed to switch/csae till the input(curr) is between 1 to 5
    HOW ?? can someone read my code and see what can be done

    Code is attached with some explanations too in the code

  2. #2
    Registered User
    Join Date
    Sep 2006
    You could put the entry for curr inside a do while loop:

      do {
        printf("Please Enter 1 to 5 for the Above World Currency \n"    );
        /*printf("you want the : \n");*/
        scanf("%d", &curr);
      }while((curr < 1) || (curr > 5));

  3. #3
    Registered User
    Join Date
    Apr 2009
    This code would done your stuff using switch case
    int main()
            int a ;
                    case 0:
                            printf("Please enter a valid number \n");
                            break ;
                    default :
                            break ;
    The main thing is we cannot write a conditional statement in the case we must give the
    integer constant only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple currency conversion program gone south!!
    By lildroopie in forum C Programming
    Replies: 1
    Last Post: 02-01-2009, 12:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Help with variables (newbee)
    By stugatza in forum C Programming
    Replies: 7
    Last Post: 08-18-2004, 10:40 AM
  5. Currency Conversion Program
    By kgraw21 in forum C Programming
    Replies: 5
    Last Post: 04-19-2002, 08:39 AM