having problems

This is a discussion on having problems within the C++ Programming forums, part of the General Programming Boards category; I am new to this and experiencing some problems. I am trying to create a converter where i type in ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    4

    having problems

    I am new to this and experiencing some problems. I am trying to create a converter where i type in a dollar amount and it will return the amount of quarters, dimes, nickles, or pennies that it would take to make that dollar amount
    Attached Files Attached Files

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,549
    So, what is your question?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    4
    Im not getting an amount as an output. When I enter a dollar amount $1 and choose to convert it to change, example pennies, the output is 011.

  4. #4
    Registered User
    Join Date
    Feb 2013
    Posts
    4
    basically it doesn't convert $1 to 100 pennies or 4 quarters

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    4
    I need help. If somebody could look at the code and tell me where I am going wrong.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    2,711
    In the following snippet from main()
    Code:
        {
            if ( money < 1 ) // if dollar amount if 1 or less end loop
                return -1;
            else
                if ( choice == 1 ) // if user types 1 then
                    return total = (money * ( PENNY * 100 )); // total pennies
                else
                    if ( choice == 2 ) // if user types 2 then
                        return ( money = ( DIME * 10)) ; // total dimes
                    else
                        if ( choice == 3 ) // if user types 3 then
                            return ( money = ( QUARTER * 4)); // total quarters
                        else
                            if ( choice == 4 ) //if user types quarter
                                return ( money = ( NICKEL * 20 )); // nickles
        }
    When a program encounters a return statement it "returns" from the function without executing any code following the return. Since this is from main() the program ends without doing anything else.

    In future please post your code in the post (contained in code tags) not as an attachment.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fread problems or memory problems
    By Lechuza in forum C Programming
    Replies: 1
    Last Post: 03-22-2009, 12:45 PM
  2. Linking problems, class problems
    By Kheila in forum C++ Programming
    Replies: 12
    Last Post: 11-22-2005, 12:47 AM
  3. I/O problems.
    By Skynet-systems in forum C++ Programming
    Replies: 10
    Last Post: 02-14-2005, 03:08 PM
  4. problems
    By pode in forum C++ Programming
    Replies: 15
    Last Post: 02-14-2002, 11:44 AM
  5. EOF problems - plz help
    By DenisGFX in forum C Programming
    Replies: 0
    Last Post: 02-06-2002, 02:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21