[ create a new paste ] login | about

Link: http://codepad.org/mn7xdI3I    [ raw code | output | fork ]

C++, pasted on May 16:
#include <iostream>

using namespace std;

int main()
{
    int den,num,dig,temp1,temp2;
    cout << "Enter the denominator.";
    cin >> den;
    cout << "Enter the numerator.";
    cin >> num;
    cout << "Enter the no of digits after decimal place.";
    cin >> dig;
    cout << num/den << "."; // Whole number part of decimal followed by decimal point
    temp1=num;
    for (int i=0;i<30;i++)
    {
        temp2=(temp1%den)*10;
        cout << temp2/den;
        temp1=temp2%den;
    }
    return 0;
}


Output:
1
2
Enter the denominator.
Floating point exception


Create a new paste based on this one


Comments: