HELP: Basic yard to feet program runs but will not perform properly.

I have been programming a basic yard to feet program in NetBeans IDE for Ubuntu.

Predictably there were bug errors which I went through and fixed until it ran. It seems to run fine and there are no errors but it won't allow me to enter any values to convert. It will only close the terminal when I press enter (even if I input numbers the only thing it does is press enter to close terminal).

Here is the terminal text:

sh: pause: not found
Please input number of yards: -1218748428-1218748428 yards equal 638722012 fe
et.Press [Enter] to close the terminal ...

That is what happens when I run the program.

Here is the original code:

//Programmer: Elliot
//Program: Yard to Feet conversion

#include <iostream>
#include <cmath>
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
int yard ,feet;

cout << "Please input number of yards: ";
cout << yard;

feet = yard * 3;

cout << yard << " yards equal to " << feet << " feet.";

return 0;

Thanks :)
cout << "Please input number of yards: ";
cout << yard;

Take a good look at that second line there, where you're trying to INPUT a value. Where's the input?

This means
"open a shell, and type in pause for me".
What happens on your shell when you type in pause?

Last edited on
I tried to input some values like the conversions of feet and yards but it comes up with the same thing.

When I type in pause into the shell then press enter it still closes.
Okay, I'll give you a bigger hint.

cout << yard;
means "output the value of yard to the screen".

cin >> yard;
means "get an input value and store it in yard".

Which of those two did you actually want, and which did you actually do?

When I type in pause into the shell then press enter it still closes.

You've missed the point. Your linux shell does not have a pause command. It does nothing. So can you see why
doesn't make your program pause? Because the pause command does not exist. This is what happens when you write code you don't understand. It's considered very bad practice in C++ to write code without understanding it.
Last edited on
closed account (2NywAqkS)
Could I just add, there is a forum for beginners. And whether you like it or not, you are a beginner.
Last edited on
I was not aware that there was a beginner forum and I shall direct my questions there next time thank you for informing me of that.

I know I am a beginner at C++. I have done it on and off for quite a few years and I am just getting back into it. I am very careful when I say I do C++ to not give the impression I am some super nerdy guru guy and I am just a beginner who likes to code.

As a beginner (which we have all established I am) there is a lot I don't understand. As is the way with all things when you are just starting out but you learn by making mistakes and getting help from other people within the community. Seen as I am a beginner there is no way I can understand right from the word go. It is like asking me to make a cake without knowing anything about baking course I won't know. Being a beginner is all about learning to understand. If I was at say your level of programming skill and I did not understand then you would be right to say programming with code I don't understand. But I am new so I don't understand right away that is the point.

I will take from the mistakes I have made here and learn from them it is called progressing. All part of learning. I appreciate your help on the one hand but you could have made the the points you put without being so patronizing. It just came across that way. But I am not here to bitch and moan and certainly not to start fights in the community.

Thanks anyway.
But I am not here to bitch and moan

288 words to say that. Could have fooled me :p
I was mealy making putting a point across. Seen as the help I have been given here (which has been helpful) has run dry. It will just descend into pointless pettiness. If you have such a great knowledge of C++ (which I am sure you do) then go and help people on the forum and use the talent you have productively not hating on beginners (which you all were once).

The best way for people to to get into and get better at programming languages is having a good community to help them. And not just help them but even at the time if they are being a bit stupid and nooby then showing patience trying to still help them. Even the greats at programming needed a helping hand at the start.
This kind of passive-aggressiveness to the lounge, please.
Topic archived. No new replies allowed.