Every time I write a program it ends very quickly as soon as it reaches the end of the program. After the calculations it displays the answer and then the console quickly closes. Here is my first program.
#include <iostream>
using namespace std;
int main ()
{
float ll, hh, area;
ll = 12;
hh =3;
area = ll * hh;
cout << "The Area of the rectangle is: " << area << endl;
return 0;
}
Is there anything I can do to make this better and let the console stay open longer?
Hazda, NO NO NO NO NO.
Do what alex79roma said, or the educated C++ users of the world will beat you up. :)
Also, use the 'insert code' button to have your code nicely formatted:
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int main ()
{
float ll, hh, area;
ll = 12;
hh =3;
area = ll * hh;
cout << "The Area of the rectangle is: " << area << endl;
return 0;
}
It's not cross-platform. Alex's and MrGuvna's solutions would work on all computers, whereas yours is specific to Windows. It's also a lot slower compared to getch(); or cin.get();.