Hello,
I have been trying to write a program that takes two fractions entered by the user and divides them. This is the code I have but unfortunatly even with a simple division of 1/2 by 1/2 gives me 1232938213982139. Something is not right and I cannot figure it out. Any suggestions would be great.
Code:
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
int num1;
int den1;
int num2;
int den2;
int fnlnum;
int fnlden;
void divideFractions(int num1, int num2, int den1, int den2);
{
fnlnum= num1 * den2;
fnlden= den1 * num2;
}
{
cout << "Dividing Fractions Calculator" << endl;
cout << "Please enter your first numerator:" << endl;
cin >> num1;
cout << "Please enter your first denominator:" << endl;
cin >> den1;
cout << "Please enter your second numerator:" << endl;
cin >> num2;
cout << "Please enter your second denominator:" << endl;
cin >> den2;
cout << num1 << "/" << den1 << " divided by " << num2
<< "/" << den2 << "=" << fnlnum << "/" << fnlden << endl;
if (den1 == 0 || den2 == 0)
{
cout << "You must enter a number other than 0" << endl;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}