+ 2
I m makin a calculator it ends as soon as the answer is displayed. How to do the "Press any key to Continue"?
9 Antworten
+ 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
+ 2
Could you please share your code?
+ 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;
}
+ 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...
+ 1
if it is in JavaScript I think I can help
+ 1
Its in C++. rn it can only plus numbers and i made it in my pc
+ 1
Thnx!
+ 1
Thnx
+ 1
Thnx