Dev C++

Hello,

Just installed Dev C++ version 4.9.9.2 with Windows XP operating system service pack 3 . I installed it in the C drive. It seems that the program is compling without any error but not running. A windows just came for a second and then disappeared and i wont be able to see my results. Any solution for that? I tried to run this program and MS visual studio it runs well.

regards-
lemon

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
32
33
34
35
36
37
38
39
40
41
42
43
44

#include <iostream>
using namespace std;

class Ratio
{ public:
    void assign(int, int);
    double convert();
    void invert();
    void print();
  private:
    int num, den;
};

int main()
{ Ratio x;
  x.assign(22,7);
  cout << "x = ";
  x.print();
  cout << " = " << x.convert() << endl;
  x.invert();
  cout << "1/x = ";  x.print();
  cout << endl;
}

void Ratio::assign(int numerator, int denominator)
{ num = numerator;
  den = denominator;
}

double Ratio::convert()
{ return double(num)/den;
}

void Ratio::invert()
{ int temp = num;
  num = den;
  den = temp;
}

void Ratio::print()
{ cout << num << '/' << den;
}
closed account (10oTURfi)
Yeah, do something to prevent program from closing, like char a; cin >> a;
It is running. You have written a console programme, so it runs in a console window. If it has to provide its own window, when it's finished, the console window closes. That's how it's meant to be.

Please read this: http://cplusplus.com/forum/beginner/1988/

and then read this: http://cplusplus.com/articles/36vU7k9E/
Topic archived. No new replies allowed.