Thread: A small problem

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

    A small problem

    How do i get the fraction for any decimal number in a variable?

    Code:
    
    
    Code:
    #include<iostream>
    using namespace std;
    
    
    int main()
    {
        double x = 1/6;
        cout << x;
        cin.get();
    }

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    with floating point division.

    double x = 1.0 / 6.0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a small problem
    By Freddy92 in forum C++ Programming
    Replies: 5
    Last Post: 12-11-2010, 04:03 PM
  2. Small C problem
    By satory in forum C Programming
    Replies: 5
    Last Post: 03-02-2006, 03:13 PM
  3. small problem
    By RPW in forum Game Programming
    Replies: 15
    Last Post: 01-06-2003, 05:53 PM
  4. A small problem with a small program
    By Wetling in forum C Programming
    Replies: 7
    Last Post: 03-25-2002, 09:45 PM
  5. I have a small problem...
    By SyntaxBubble in forum Windows Programming
    Replies: 0
    Last Post: 12-01-2001, 04:05 PM