Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

In main, create an integer to store the number of seconds that have passed in the day ( I ll refer to this as clockSec

In main, create an integer to store the number of seconds that have passed in the day (Ill refer to this as
clockSec).
Notice that you will want to avoid overflow so what if the number of seconds was > the 86400 seconds
in a day? Can we use % to ensure the value isnt too large?
The TA or I will also go over the rand function but the simplified form:
Include time.h and stdlib.h
Call srand(time(NULL)); before getting a random number. This uses the clock time on the
computer (so pretty random) to set the random number generator.
A call to rand() returns a random number between 0 and RAND_MAX. How can you make sure
the range is between 0 and 86400?
Set clockSec to this random value.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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