Score Entering

This is a discussion on Score Entering within the C++ Programming forums, part of the General Programming Boards category; I'm having troubles with a program of mine, I'm trying to create code that will let a user enter scores ...

  1. #1
    ryn
    ryn is offline
    Registered User
    Join Date
    Mar 2002
    Posts
    3

    Score Entering

    I'm having troubles with a program of mine, I'm trying to create code that will let a user enter scores but stop entering the scores when they type a certain number, I have everything working in this program except for my function where I enter the numbers. I can enter numbers but when i type -1 to go back to the main menu it doesn't do much, I would appreciate if someone could get me a little code for this function. Thanks for your time

  2. #2
    Unregistered
    Guest
    how are you determining if its -1, your using an if statement right?

  3. #3
    ryn
    ryn is offline
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    Yes, I am using an if statement. And I am just using -1 as an example, anything will do.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    int scores = 0;
    cin>>scores;
    while ( scores != -1 ) {
      // Process the score
      cin>>scores;
    }
    -Prelude
    My best code is written with the delete key.

  5. #5
    ryn
    ryn is offline
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    I used your idea but it still wasn't working right, I finally figured out though that i needed (i-1 != -1) instead of (i != 0) but the suggestion above made it alot easier also, thank you all very much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting lowest and highest score from array
    By sjalesho in forum C Programming
    Replies: 6
    Last Post: 03-01-2011, 06:24 PM
  2. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 01:33 PM
  3. Frustated with mess table printing
    By benedicttobias in forum C Programming
    Replies: 6
    Last Post: 04-16-2009, 06:50 PM
  4. trouble with creating a loop to read certain number of inputs
    By import tuner650 in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2008, 08:28 PM
  5. Few errors I can't figure out
    By burn in forum C++ Programming
    Replies: 8
    Last Post: 05-07-2002, 09:43 PM

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