Hi,
Sorry for the bad thread name, I couldnt think what to put
I only started programming in C++ today, so please point out anything which I am doing wrong - I don't want to get bad habits this early on
I have made this program, which asks you for a number, then adds 5 to it and displays the result. Then waits for keypress before terminating:
The problem I have is, the program seems to wait for keypress before it displays the result and the following text. Could anyone please point out where I have gone wrong?Code:#include <iostream.h> #include <conio.h> int main () { int a; int result; int numtoadd; cout << "Number to add 5 to\n"; cin >> numtoadd; a = 5; result = numtoadd + a; cout << result; cout << "\nThat is the answer to " << numtoadd << " plus 5\n\n"; cout << "Press any key to continue...\n"; getch(); cout<<"A key was pressed... exiting the program"; return 0; }
Thanks very much for any help