While loop C++ menu

User Tag List

Results 1 to 3 of 3
  1. #1
    lolicon123's Avatar Member
    Reputation
    1
    Join Date
    Oct 2008
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    While loop C++

    so if the user enters let's say 636 the program will subtract 100 each time until summa is < 100 and then print out summa which would in this case be 36
    this aint working thought any ideas on what i did wrong? oh and i was thinking too use i++ to record how many times it subtract 100 from 636 it should work right? since it should add 1 each time summa gets reduced by 100

    note: not the whole code just the one i'm getting error from




    while (summa > 100)
    {

    (summa - 100);
    i++;
    }


    cout << summa << endl;
    Last edited by lolicon123; 03-19-2010 at 08:47 AM.

    While loop C++
  2. #2
    Danne206's Avatar Contributor
    Reputation
    183
    Join Date
    Jan 2008
    Posts
    717
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no idea how to do this in C++, but in C#, I'd do something similar:
    Code:
     Console.WriteLine("Enter a number: "); //Tells the user to enter a value
                int summa = int.Parse(Console.ReadLine()); //Read the int with ReadLine(), had to do it like this, string wont work
                while (summa > 100)
                {
                    summa = summa - 100; //subtract summa with 100 each time it's > 100
                }
                Console.WriteLine(summa); //Write the value of summa when it's < 100
    You can probably port this to C++ easily.

    EDIT: Example:
    Originally Posted by My program output
    Enter a number:
    891
    91
    Press any key to continue . . .
    EDIT2: Hope I did understand everything right. And to any other C# programmer, this is probably a bad way to do it, just like everything else I program. Live with it - it works.
    Last edited by Danne206; 03-19-2010 at 09:31 AM.
    Dahnniel [DOT] s [AT] gmail [DOT] com

  3. #3
    Tigurius's Avatar Member
    Reputation
    300
    Join Date
    Jun 2008
    Posts
    519
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    Change:
    (summa - 100);
    to
    summa -= 100;
    Like my work? Support Me! ;D

Similar Threads

  1. [How-To] Solution to No Poke stop found and soft ban loop while botting using All kinds of bot
    By uploader619 in forum Pokemon GO Hacks|Cheats
    Replies: 24
    Last Post: 08-08-2016, 02:25 AM
  2. Waypoints -> Do you just use while loops on x,y,z values?
    By zewt in forum SWTOR Bots and Programs
    Replies: 6
    Last Post: 01-31-2012, 11:09 AM
  3. Empty While Loop - good idea?
    By abuckau907 in forum Programming
    Replies: 1
    Last Post: 07-02-2009, 05:25 PM
  4. Dance while you lay on your back
    By KuRIoS in forum World of Warcraft Exploits
    Replies: 14
    Last Post: 07-31-2006, 04:40 AM
  5. Your First Mount - Where to Get the Cash while Grinding
    By Matt in forum World of Warcraft Guides
    Replies: 2
    Last Post: 05-12-2006, 06:58 PM
All times are GMT -5. The time now is 07:24 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search