Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C++ code using a for loop which calculates the sum of Z integers inputted by a user . Z is a random number

Create a C++ code using a for loop which calculates the sum of Z integers inputted by a user. Z is a random number which is computer generated. Z is between 5 and 15 (both included).

Use the these libraries for rand(),srand(), and time() support.

#include #include

setting seed: srand(time(NULL))

Use this for generating a random number: rand()

BELOW IS THE CODE I HAVE CREATED. PLEASE ALSO EXPLAIN WHY IT IS NOT OUTPUTTING THE CORRECT OUTPUT

image text in transcribed

Einclude 2 #include (#includectime> using namespace std; int main() { 4 9 10 int num; int sum = 0; int N; 12 13 14 15 16 17 18 19 20 211 1 srand (time (NULL)); for (int N -5 rand () % 6; N.(2* N); ++N) + cout 33 "Enter " 5 N cin >>num; 2B 24 25 26 27 28 29 30 1 32 integers :

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions