Auto-Exit

This is a discussion on Auto-Exit within the C++ Programming forums, part of the General Programming Boards category; First off, I'd like to say hello to y'all, and thanks in advance for responding (assuming you do so in ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    1

    Auto-Exit

    First off, I'd like to say hello to y'all, and thanks in advance for responding (assuming you do so in the first place).

    I'm a beginning programmer (if even that), and was absolutely ecstatic when I used a free compiler (Bloodshed Dev-C++) to create my first "program". The purpose was originally to convert celsius to fahrenheit, and later to "count" to 10, to test the "while" function.

    After compiling the program and initiating it, I input the number, hit enter....and it dissapeared. Closer investigation revealed the thing went freaking fast, finished, and decided it was done. With the loop "counter", it would zoom through anything less than 1000 and do the same thing.

    I have the code I used for both of them at the bottom; can I "stagnate" the program so I can see the results, and, in the case of the "counting" program, can I slow it down abit? Thanks again.


    And now, the code:

    Code:
    //
    // Program to convert temperature from Celsius degree
    // units into Fahrenheit degree units:
    // Fahrenheit = Celsius * (212 - 32)/100 + 32
    //
    #include <stdio.h>
    #include <iostream.h>
    
    int main(int nNumberofArgs, char* pszArgs[])
    {
        // enter the temperature in Celsius
        int celsius;
        cout << "Enter the temperature in Celsius:";
        cin >> celsius;
        
        // calculate conversion factor for Celsius
        // to Fahrenheit
        int factor;
        factor = 212 - 32;
        
        //use conversion factor to convert Celsius
        // into Fahrenheit values
        int fahrenheit;
        fahrenheit = factor * celsius/100 + 32;
        
        // output the results
        cout << "Fahrenheit value is:";
        cout << fahrenheit;
        
        return 0;
    }

    And...


    Code:
    //WhileDemo - input a loop count. Loop while outputting astring arg number
    //            of times
    #include <stdio.h>
    #include <iostream.h>
    
    int main(int arg, char* pszArgs[])
    {
        // input the loop count
        int loopCount;
        cout << "Enter loopCount: ";
        cin >> loopCount;
        
        while (loopCount > 0)
        {
              loopCount = loopCount - 1;
              cout << "Only " << loopCount << " loops to go\n";
        }
        return 0;
    }

  2. #2
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    FAQ you!

    and you can use the windows-specific Sleep function to slow down the while loop.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Odd memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 05-25-2006, 01:56 AM
  2. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  3. Dynamic array of pointers
    By csisz3r in forum C Programming
    Replies: 8
    Last Post: 09-25-2005, 03:06 PM
  4. Code: An auto expanding array (or how to use gets() safely).
    By anonytmouse in forum Windows Programming
    Replies: 0
    Last Post: 08-10-2004, 01:13 AM
  5. exit() ?
    By smd in forum C++ Programming
    Replies: 4
    Last Post: 06-26-2002, 05:31 PM

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