Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

good afternoon this is for c++ i have this code so far but my professor doesn't want us to use array i don't know really

image text in transcribed

good afternoon this is for c++ i have this code so far but my professor doesn't want us to use array i don't know really how to use int variable to store the random numbers starting with the digits 1 to 10 please help

#include #include #include

int main() { std::srand(static_cast(std::time(nullptr))); int counters[10] = {0};

for (int count = 1; count

for (int i = 0; i

return 0; }

Write a program that tests the function that generates random integers. Your program should generate 10,000 random integers between 0 and 99 , and then count the number of generated integers that begin with each digit from 0 to 9 . Because the random number generator creates uniformly distributed integers, the number of integers in each category should be approximately equal. Write a function that returns a randomly generated integer between 0 and 99 . Call this function to generate each integer. We haven't introduced the C++ array, so use 10 different int variables - count0, count1, count2, count 3,, count 9 - to count the number of generated integers that fall into each category. For instance, count 3 will hold the count of the integers that begin with the digit 3. Use a switch statement in your program. There should be a case for each digit. Once all the integers have been counted, your program should print 10 lines giving the results of your test a line for each digit k that gives a message similar to: The number of integers beginning with digit k is countk. (k and countk will have specific integer values.)

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_2

Step: 3

blur-text-image_3

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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

What is the speed of an electron whose kinetic energy is 1.12 MeV?

Answered: 1 week ago

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago

Question

2. What, according to Sergey, was strange at this meeting?

Answered: 1 week ago