Thread: deciaml place help

  1. #1
    Registered User
    Join Date
    Dec 2002

    decimal place help

    I am new at programming using C++. I am trying to write a program where ouput needs to be formatted to fit certain decimal place criteria. I am using Visual Basic C++. The folowing is just some of the program I wrote:

    cout << fixed << showpoint;

    then some equations, then,

    cout << setprecision(0) << htInches << " inches" << endl;
    cout << setprecision(2) << htMeters << " meters" <<endl;
    cout << setprecision(0) << htCentimeters<< " centimeters" << endl;

    I am racking my brain trying to get this to work. I have been all through the book also. No help at all. Any help I can get would be appreciated. Thank you in advance.
    Last edited by artgirloc; 12-03-2002 at 07:00 PM.

  2. #2
    Registered User
    Join Date
    Dec 2002

    Desparate for help

    Any suggestions would be great. Anything really. Thank you.

  3. #3
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    hmm are you using visual basic or visual c++...hehe..thats my first question..but it seems like you are using visual c++

    here is code:
    #include <iostream>
    using namespace std;
    int main()
    	float x = 1.2345f;
    	cout << x << endl;
    	return 0;
    well it should output only 1.235 since precision is set to 3 it will only out 3 digits after the decimal which is the 4 but it's rounding it up to a 5 because of the 5. hope that helps

  4. #4
    Registered User
    Join Date
    Dec 2002

    I got it

    I got it figured out. Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to place controls?
    By C_ntua in forum C# Programming
    Replies: 3
    Last Post: 12-19-2008, 02:16 PM
  2. How to NOT reverse a string in place.
    By cdalten in forum C Programming
    Replies: 2
    Last Post: 01-12-2006, 09:06 AM
  3. A place to start - mac or pc?
    By GCat in forum C++ Programming
    Replies: 12
    Last Post: 11-19-2004, 12:21 PM
  4. Berlin: Searching for a place to stay
    By fabs in forum A Brief History of
    Replies: 0
    Last Post: 01-14-2002, 02:18 AM
  5. Where is a good place to start?!
    By bobthefish3 in forum Game Programming
    Replies: 1
    Last Post: 10-09-2001, 11:28 AM