Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I am solving this c-programming question, but I am stuck. Can anyone help me with this question? b) Given the C function shown in

Hi I am solving this c-programming question, but I am stuck. Can anyone help me with this question?

image text in transcribedimage text in transcribed

b) Given the C function shown in Figure 1 , answer the following questions: i. What is its intended functionality? ii. For which valid values of min and max does the function work as intended? iii. What are the major issues of this function? iv. Write a re-implementation of the function that fixes the major issues present in the function. Comment your code accordingly, explaining how your solution solves the problems. \begin{tabular}{|lll|} \hline 1 & int GetRandomnumber (int min, int max) \\ 2 & \{ & \\ 3 & int number; \\ 4 & do \\ 5 & \{ \\ 6 & number = random (); \\ 7 & \}while ( (number( number >max)); \\ 8 & return number; \\ 9 & \} & \\ \hline \end{tabular}

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

Students also viewed these Databases questions

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago

Question

Can workers be trained in ethics? How? Defend your answer.

Answered: 1 week ago