Program to convert fraction to decimal, C/C++ Programming

Program to convert fraction to decimal:

int main()

{

                float num, denom;     // numerator and denominator of fraction

                float value;          // value of fraction as decimal

 

                cout << "Convert a fraction to a decimal\n";

                cout << "Numerator: ";

                cin >> num;

                cout << "Denominator: ";

                cin >> denom;

 

                value = num / denom;  // convert fraction to decimal

 

                cout << '\n' << num << '/' << denom << '=' << value;

 

                return 0;

}

Posted Date: 10/18/2012 7:56:21 AM | Location : United States







Related Discussions:- Program to convert fraction to decimal, Assignment Help, Ask Question on Program to convert fraction to decimal, Get Answer, Expert's Help, Program to convert fraction to decimal Discussions

Write discussion on Program to convert fraction to decimal
Your posts are moderated
Related Questions
A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

what is the difference between call by reference and call by pointer method?

Write a simple generic version of method isEqualTo that compares its two arguments with the equals method and returns true if they are equal and false otherwise. Use this generic m

write an algorithm to swap values without using third variable

how are metric numer change the number of metric

Define Bitwise-Shift Operators? The shift operators perform suitable shift by operator on the right to the operator on the left. The right operator should be positive. The va

Write a function to calculate the exchange rate of pounds to dollars  Answer       Td = 2xTp   The parameter passed over is the number of pounds and returned the value in do

Define External Storage Class - computer programming? When a variable is declared outside a function the storage is permanently assigned to it and its storage class is 'extern'

Four cells, each with an internal resistance of 0.40 ? and an e.m.f. of 2.5 V are connected in series to a load of 38.40 ?. (a) Verify the current flowing in the circuit and t