2. (5.12 in 8e) Answer each of the following questions:a) What does it mean to choose numbers "at random"?b) Why is the rand function useful for simulating games of chance?c) Why would you randomize a program by using srand? Under what circumstances is itdesirable not to randomize?d) Why is it often necessary to scale and/or shift the values produced by rand?3. Define an array of 100 ints, and write a loop (including the body) to initialize every element inthe array to 0. You can name the array whatever you'd like.4. In C, strings have a terminating character at the end of the array, while, for example, integerarrays do not. Why do you think this is?

Question
Asked Oct 21, 2019
4 views

Question 4

2. (5.12 in 8e) Answer each of the following questions:
a) What does it mean to choose numbers "at random"?
b) Why is the rand function useful for simulating games of chance?
c) Why would you randomize a program by using srand? Under what circumstances is it
desirable not to randomize?
d) Why is it often necessary to scale and/or shift the values produced by rand?
3. Define an array of 100 ints, and write a loop (including the body) to initialize every element in
the array to 0. You can name the array whatever you'd like.
4. In C, strings have a terminating character at the end of the array, while, for example, integer
arrays do not. Why do you think this is?
help_outline

Image Transcriptionclose

2. (5.12 in 8e) Answer each of the following questions: a) What does it mean to choose numbers "at random"? b) Why is the rand function useful for simulating games of chance? c) Why would you randomize a program by using srand? Under what circumstances is it desirable not to randomize? d) Why is it often necessary to scale and/or shift the values produced by rand? 3. Define an array of 100 ints, and write a loop (including the body) to initialize every element in the array to 0. You can name the array whatever you'd like. 4. In C, strings have a terminating character at the end of the array, while, for example, integer arrays do not. Why do you think this is?

fullscreen
check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1

In C, strings are ended with a special null character to mark its end. Hence, when a string is stored in an array, a null character also gets stored. Generally, char arrays in C may not end with a nu...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Write an expression using membership operators that prints "Special number" if special_num is one of...

A: Python Program:#Declare and initialize the variablespecial_list = [-99, 0, 44]#Prompt the user to gi...

question_answer

Q: Problem 1 consists of multiple parts. You should finish one part and ensure that it works before mov...

A: Hello. Since your question has multiple sub-parts, we will solve first three sub-parts for you. If y...

question_answer

Q: Python 3.7.4 Use the file object output to write the string "3.14159" to a file called pi.

A: Following is the program code which writes the string "3.14159" to a file called pi.To open a file c...

question_answer

Q: Consider the following nested loop construct. Categorize its efficiency in terms of the variable n u...

A: Categorization of efficiency in terms of “n” using “big-o” notation:The statement “x*=2” is given in...

question_answer

Q: I need some help arranging these countries in a C++ program : China: 1,433,783,686 India: 1,366,417,...

A: Program AlgorithmDeclare two arrays named country and population of size 14.Using for loop enter the...

question_answer

Q: Write a program in Java Eclipse that does the following:a) create a 2D Ragged array with columns and...

A: Create a Main class and all required methods to print Ragged array elements. And create all methods ...

question_answer

Q: Python 3.7.4 Write the code to call the function named send_signal. There are no parameters for this...

A: To call the given function without parameter we need to write it as send_signal(). The following is ...

question_answer

Q: Consider partitioning the list {1,4,0,1,1,1,2,3,1,0,4,4,1,2,0,1} where the first element ofthe array...

A: Program description for part (A)The program for part A works by using two new arrays for the left an...

question_answer

Q: Hello good afternoon,   Write a C++ program that reads data from an input file, takes the data and c...

A: Program designcreate two functions for printing name, and computing and printing graderead data from...