I'm wondering how to remove the stuff at the end of the console, where it says the execution time, press any key to continue, and what the process returned. I am using Codeblocks.

As well, I am wondering when I type in a letter, (for example, the letter h), it returns the number 51276552. Is there a way that I can restrict the user to only input a number?

The code is:

#include <iostream>

using namespace std;

int main()
{
    int years;

    cout << "How old are you? ";
    cin >> years;
    cout << "You are " << years * 12  << " months old.";
}

As well, I am wondering when I type in a letter, (for example, the letter h), it returns the number 51276552. Is there a way that I can restrict the user to only input a number?

In your code, it doesn't "return" a large number, it actually fails (since "h" isn't a number), and the number in years is uninitialized garbage.

You can check cin for an error condition via if (cin.fail()) { ... } , and if you want to restrict the user, create a loop that reports the error, re-prompts the user and re-inputs the desired value until the value is valid.

I'm wondering how to remove the stuff at the end of the console, where it says the execution time, press any key to continue, and what the process returned. I am using Codeblocks.

Run the program directly from the console. It's CodeBlocks itself that's outputting that stuff.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.