#include <iostream>
using namespace std;

int main()
{
	int length;
	length = 7;

	cout << "The length is " << length;
	return 0;
}

When i run the program, it outputs everything but the screen comes on real fast and then closes and i cant get it to stay running

2 options for this problem:

1. Add

cin.get();

just before your return. This waits for user input before exiting the program.

2. Run the program manually from a terminal. Then you can see the output even if the program exits

~J

>I prefer option 2.
Same here.
But everyone should use option 2 if you are designing a converter, or a filter. It helps other program to use your program's output as their input.

#include <iostream>
using namespace std;

int main()
{
	double f;
	double m;

	cout << "Enter the length in feet ";
	cin >> f;

	m = f / 3.28;

	cout << f << " feet equals " << m << " meters";

	cin.get();

	return 0;
}

Im having the same problem again. I have no problem entering in f, but the out put does the exact same thing. it says the cout statement but it disappears really fast. even when im using cin.get()

You did not flushed the stream.
Read http://www.daniweb.com/forums/thread90228.html
Use cin.ignore(); to do this:

#include <iostream>
using namespace std;

int main()
{
    double f;
    double m;
    cout << "Enter the length in feet ";
    cin >> f;
    m = f / 3.28;
    cout << f << " feet equals " << m << " meters";
    cin.ignore();
    cin.get();
    return 0;
}

Also, always post your code in the code tags:
[code=cplusplus] //your code goes here

[/code]

This article has been dead for over six months. Start a new discussion instead.