Multiple user input and task execution - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26

Thread: Multiple user input and task execution

  1. #16
    Join Date
    May 2017
    Posts
    175

    Re: Multiple user input and task execution

    so I have to reset the i and n used inside loop ? can you explain more ? thx

  2. #17
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    Quote Originally Posted by david16 View Post
    your design will check for each input . I wanted to enter multiple input till -1 is entered it will exit loop and display the result you see?
    my prog is working but not counting all perfects it only do count first 1 visible no the list can you tell me whats wrong with that loop ? thanks
    See 1st line of my post #14.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  3. #18
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    Quote Originally Posted by david16 View Post
    so I have to reset the i and n used inside loop ? can you explain more ? thx
    No. You have to reset i and sum within the outer while loop but before entering the inner while loop. See AvDav's code in post #3.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  4. #19
    Join Date
    May 2017
    Posts
    175

    Re: Multiple user input and task execution

    your program in post #14 is not display the number of perfect its not checking for it and when I enter -1 it close automatically without displaying the number of perfect found . Can you plz tell me if is it possible to make it on the one I wrote . I think I will understand it better if it was just loops because function is doing something else I was asked to do it with simple loop and inner loop you see .. thx again

  5. #20
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    it close automatically without displaying the number of perfect found
    then just put
    Code:
    system("pause");
    at the end - like in your code.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  6. #21
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    Can you plz tell me if is it possible to make it on the one I wrote .
    yes - I explained how in post #18.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  7. #22
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    If you don't understand what is happening in the code, then use the debugger to trace through the code and see the values of the variables as execution progresses. Knowing how to use the debugger is a vital skill that needs to be learnt - and now seems a good time.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  8. #23
    Join Date
    May 2017
    Posts
    175

    Re: Multiple user input and task execution

    I did reset i and sum in outer loop and it worked thx for your help . I did trace and found the prob thx alot that was helpful

  9. #24
    Join Date
    May 2017
    Posts
    175

    Re: Multiple user input and task execution

    I have a question about validation that I couldn't find an answer for it . if we were asked to validate each input as integer which means greater than 0 ( positive numbers) but the sentinel value is -1 and when user enter -1 it should display the number of perfects . Now is there any possible way to ignore -1 in validation and refuse any other negative input but use it as sentinel for the prog ?? . thx
    Last edited by david16; June 13th, 2017 at 02:46 PM.

  10. #25
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,787

    Re: Multiple user input and task execution

    For validation of input, see my code in post #14.

    Also consider
    Code:
    int num;
    
    do {
        cin >> num;
    
        if (num == -1 || num > 0) {
            //number OK
            if (num > 0) {
                //Got positive number so process
            }
        } else
             //Bad number
        }
    } while (num != -1);
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.1)

  11. #26
    Join Date
    May 2017
    Posts
    175

    Re: Multiple user input and task execution

    I'm going to try adding that to my prog . Thx for your help . I will have to continue the other parts

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)