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
  1. #16
    Join Date
    May 2017
    Posts
    182

    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 offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #18
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #19
    Join Date
    May 2017
    Posts
    182

    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 offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #21
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #22
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #23
    Join Date
    May 2017
    Posts
    182

    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
    182

    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 offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. 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/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  11. #26
    Join Date
    May 2017
    Posts
    182

    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
  •  





Click Here to Expand Forum to Full Width

Featured