I compiled a calculator, with only *, when I start the program it says that I shall put in first number, and when I put in secound it exits, how do I do so it stays? cause I don't want anyone to run it by DOS :P
This is a discussion on Help! within the C++ Programming forums, part of the General Programming Boards category; I compiled a calculator, with only *, when I start the program it says that I shall put in first ...
I compiled a calculator, with only *, when I start the program it says that I shall put in first number, and when I put in secound it exits, how do I do so it stays? cause I don't want anyone to run it by DOS :P
Can you post the source code?
edit: Is this a console or Win 32 app?
if its a console app, then this should work.
Code:#include <stdlib.h> ... //where you want the app to pause SYSTEM("PAUSE") ...
Last edited by Death_Wraith; 05-04-2004 at 11:47 AM.
#include <iostream.h>
int mult(int x, int y);
int main()
{
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
return 0;
}
int mult(int x, int y)
{
return x*y;
}
\\i dont know if it is console or win32 and where i shall put the code, im a newbie on c++
Maybe...
Code:#include <iostream> #include <cstdio> using namespace std; int mult(int x, int y); int main() { int x, y; cout<<"Please input two numbers to be multiplied: "; cin>>x>>y; cout<<"The product of your two numbers is "<<mult(x, y); getchar(); getchar(); return 0; } int mult(int x, int y) { return x*y; }
I used to be an adventurer like you... then I took an arrow to the knee.
Thnks a lot it worked =)