Thread: Help!

  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,817
    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;
    }
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

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

Popular pages Recent additions subscribe to a feed