Help!

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 ...

  1. #1
    Banned
    Join Date
    May 2004
    Posts
    55

    Help!

    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

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    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.

  3. #3
    Banned
    Join Date
    May 2004
    Posts
    55
    #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++

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,673
    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.

  5. #5
    Banned
    Join Date
    May 2004
    Posts
    55
    Thnks a lot it worked =)

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21