-
June 13th, 2017, 01:54 PM
#16
Re: Multiple user input and task execution
so I have to reset the i and n used inside loop ? can you explain more ? thx
-
June 13th, 2017, 02:03 PM
#17
Re: Multiple user input and task execution
Originally Posted by david16
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)
-
June 13th, 2017, 02:06 PM
#18
Re: Multiple user input and task execution
Originally Posted by david16
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)
-
June 13th, 2017, 02:13 PM
#19
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
-
June 13th, 2017, 02:20 PM
#20
Re: Multiple user input and task execution
it close automatically without displaying the number of perfect found
then just put
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)
-
June 13th, 2017, 02:22 PM
#21
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)
-
June 13th, 2017, 02:30 PM
#22
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)
-
June 13th, 2017, 02:37 PM
#23
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
-
June 13th, 2017, 02:43 PM
#24
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.
-
June 13th, 2017, 02:53 PM
#25
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)
-
June 13th, 2017, 03:01 PM
#26
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|