Question: Question 4 Use a for loop to write a program that calculates the sum of N integers entered by the user. N is a computer
Question 4
Use a for loop to write a program that calculates the sum of N integers entered by the
user. N is a computer generated random number between 5 and 15 (both inclusive).
1. Repeat the program using a while loop
2. Test plan for question 4 is only done once, for any of the three loops (pick one
loop type and run the test cases you need to make sure youre code works
correctly for all 2 loops, so you still need to test them).
Provide 4 valid test cases. No invalid test cases.
Note:
Use the following libraries for rand(),srand(), and time() support.
#include
#include
Use this for setting a seed: srand(time(NULL))
Use this for generating a random number: rand()
| Test # | Valid / Invalid Data | Description of test | Input Value | Actual Output | Test Pass / Fail |
| 1 | Valid |
|
|
| Pass |
| 2 | Valid |
|
|
| Pass |
| 3 | Valid |
|
|
| Pass |
| 4 | Valid |
|
|
| Pass |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
