When I press enter after the execution of the code, it doesn't terminate and tell me the process time etc. it just skips a line.

#include <iostream>

using namespace std;

int main()
{
    cout<<"Please enter an integer.\n";
    int intege;
    int integ;


    for ( int inte = 1; inte = 1; )
    {
        cin>> intege;
        cin.ignore();
        cout<<"Please enter it again.";
        cin>> integ;
        cin.ignore();

        if (intege==integ)
        {
        inte=0;
        cout<<"Thank You, please hit enter to end the program."<<endl;
        }

        else
        {
        inte=1;
        cout<<"Your inputs don't quite seem to match. Please type them again."<<endl;
        }

    }

}

Hi

Need to add:

return 0;

at line 33

This will force a "return" from function "main" and terminate your program.

Cheers
Milton

That didn't help. The program still didn't terminate until I killed it manually (close button).

Sorry
I missed the problem in your for loop.
A do while loop will be better suited to what you want to achieve.

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    cout<<"Please enter an integer.\n";
    int intege;
    int integ;
	bool result;


    do 
    {
        cin>> intege;
        cin.ignore();
        cout<<"Please enter it again." <<endl;
        cin>> integ;
        cin.ignore();

        if (intege==integ)
        {
                cout<<"Thank You, please hit enter to end the program."<<endl;
				getch();
				result = true;
        }

        else
        {
			cout<<"Your inputs don't quite seem to match. Please type them again."<<endl;
			result = false;
        }
	}
	while (!result);
 return 0;
}

Cheers
Milton

Thank you, milton. Inspired by your code, I moved my return(0); into my if statement. My only question is why it didn't work outside the statement?

This question has already been answered. Start a new discussion instead.