Question: Read and write from/to same file Read a set of integers from a file from a file (called called random.txt ). Find the average of

Read and write from/to same file

Read a set of integers from a file from a file (called called random.txt). Find the average of those numbers then add a random number between 0 and 10 and write this result to the same file.

Hint: Don't forget to close files that you need to open again.

Also, srand () is used just once in a program to seed the initial number. For grading purposes we need you to use srand (1), so we always get the same set of numbers (since the machine has to grade your work). Then rand( ) uses that seed number and the previous answer to generate a seemingly random number. rand provides a number between zero and a very large numberso you may consider how we can get a range between zero and ten. Hint: Remember that the modulus (%) operator provides the remainder after division.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!