+ 2

I m makin a calculator it ends as soon as the answer is displayed. How to do the "Press any key to Continue"?

11th Jun 2017, 8:20 AM
rishiraj deori
rishiraj deori - avatar
9 Answers
+ 3
just add following lines before last } cout <<"Press any key to continue..."; getch (); //include conio.h Are you using Turbo C++ compilers. In that case, press Alt + 0 to switch to output window
11th Jun 2017, 10:01 AM
ā¤ĻāĨ‡ā¤ĩāĨ‡ā¤‚ā¤ĻāĨā¤° ā¤Žā¤šā¤žā¤œā¤¨ (Devender)
ā¤ĻāĨ‡ā¤ĩāĨ‡ā¤‚ā¤ĻāĨā¤° ā¤Žā¤šā¤žā¤œā¤¨ (Devender) - avatar
+ 2
Could you please share your code?
11th Jun 2017, 8:28 AM
ā¤ĻāĨ‡ā¤ĩāĨ‡ā¤‚ā¤ĻāĨā¤° ā¤Žā¤šā¤žā¤œā¤¨ (Devender)
ā¤ĻāĨ‡ā¤ĩāĨ‡ā¤‚ā¤ĻāĨā¤° ā¤Žā¤šā¤žā¤œā¤¨ (Devender) - avatar
+ 2
use while loop to make your process repeat. please see the following example. int x,y; char exit; while(exit!='x'){ cin >> x >> y; cout << x+y <<endl; cout << "press x to exit or any key to continue"; cin << exit; }
11th Jun 2017, 10:05 AM
NSA94
NSA94 - avatar
+ 2
Use this function in the end: //You will have to include conio.h and cstdlib for this, otherwise you use the one given later... void process() { cout<<"Press any key to continue... "; char key=getch(); if(key) exit(0); } main() { //Your calc. code cout<<endl; process(); } //This program will terminate the code if any key is pressed after the calculator's execution... void process2() { cout<<"Press any key to continue... "; char key=cin.get(); if(key) exit(0); } //Note that if you use process 2 instead, you will have to press enter after all keys, but if you just press enter, it will work fine...
11th Jun 2017, 10:08 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
if it is in JavaScript I think I can help
11th Jun 2017, 8:35 AM
_Retr0/-
_Retr0/- - avatar
+ 1
Its in C++. rn it can only plus numbers and i made it in my pc
11th Jun 2017, 9:53 AM
rishiraj deori
rishiraj deori - avatar
+ 1
Thnx!
11th Jun 2017, 10:02 AM
rishiraj deori
rishiraj deori - avatar
+ 1
Thnx
11th Jun 2017, 10:06 AM
rishiraj deori
rishiraj deori - avatar
+ 1
Thnx
11th Jun 2017, 2:56 PM
rishiraj deori
rishiraj deori - avatar