MECH 215 Lecture Notes - Lecture 5: Local Variable, Global Variable, Function Prototype

117 views36 pages

Document Summary

There is a c-based library which contains several types, and functions which are used in manipulating program time. This library contains a function called time() which returns a value of type time_t, which is an integral type. If one invokes the function time() with argument of 0, function time() returns the current value of time. If we cast the return type to an unsigned int , then this value can be used as the seed value to function srand(). Thus, new a new pseudorandom sequence of numbers can be generated everytime a program is run, without asking the user for a seed value: // time() to return a value which is used. #include // needed for rand() and srand() Every time we now run the program, a different sequence of numbers is produced: ted@flash programs 9:54pm >random_with_time. In addition to library functions c++ allows the programmer to define their own functions.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents