Thread: double numbers

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    57

    double numbers

    can someone tell me why this doesnt produce the rigth number?

    Code:
    #include <iostream.h>
    
    int main()
    {
    	double ounces = 0;
    	double tons = 0;
    	double boxes = 0;
    	cout << "enter number of ounces\n";
    	cin >> ounces;
    	tons = ounces / 35,273.92;
    	cout << tons << endl;
    	cout << ounces << endl;
    	boxes = 35,273.92 / ounces;
    	cout << boxes;
    	return 0;
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >can someone tell me why this doesnt produce the rigth number?
    >tons = ounces / 35,273.92;
    >boxes = 35,273.92 / ounces;
    My first guess would be because you don't include commas in floating-point literals in C++.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 10:53 AM
  2. C++ to C Conversion
    By dicon in forum C Programming
    Replies: 7
    Last Post: 06-11-2007, 08:38 PM
  3. Help with multi function progam
    By WackoWolf in forum C Programming
    Replies: 22
    Last Post: 10-13-2005, 02:56 AM
  4. getline problem
    By scottmanc in forum C++ Programming
    Replies: 9
    Last Post: 04-13-2003, 09:27 PM
  5. error message, what does it mean?
    By Shy_girl_311 in forum C++ Programming
    Replies: 5
    Last Post: 11-09-2001, 09:54 PM