What am I missing?

I'm trying to write a program that will read and store the numerators and denominators of two fractions as integer values. i.e. solve , 1/4*1/2 to equal 1/8 or 0.125. This is what I have so far, no errors pop up but the .exe window that pops up is blank and doesn't output any of the statements. Thanks for any help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdafx.h"



#include <iostream>
using namespace std;

int main()
{
	int n1;
	int n2;
	int d1;
	int d2;
	int n;
	int d;
	float f;
	cout<<"Enter numerator 1:";
	cin>>n1;
	cout<<"Enter denominator 1:";
	cin>>d1;
	cout<<"Enter numerator 2:";
	cin>>n2;
	cout<<"Enter denominator 2:";
	cin>>d2;
	n=n1*n2;
	d=d1*d2;
	f=n/d;
	cout<<"ans = "<<f;
	return 0;
	
}
WOW! It must work-at least with me(Code::Blocks with MinGW).
Last edited on
i got it to stay up and ask the outputs, but after i enter the "Enter denominator 2:"; it closes and doesnt show the answer thanks for any help
yeah, you must add cin.get(); before the return statement.
Topic archived. No new replies allowed.