0% found this document useful (0 votes)
6 views16 pages

Chap 04 4

The document discusses standard functions in C including math functions and random number generation. It provides examples of functions like ceil, floor, rand, and srand. It includes the note that srand must be called only once for each random number series. It also provides programs demonstrating random number generation.

Uploaded by

manisha tapale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views16 pages

Chap 04 4

The document discusses standard functions in C including math functions and random number generation. It provides examples of functions like ceil, floor, rand, and srand. It includes the note that srand must be called only once for each random number series. It also provides programs demonstrating random number generation.

Uploaded by

manisha tapale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

4-5 Standard Functions

C provides a rich collection of standard functions


whose definitions have been written and are ready to
be used in our programs. To use these functions, we
must include their function declarations.

Topics discussed in this section:


Math Functions
Random Numbers

Computer Science: A Structured Programming Approach Using C 1


FIGURE 4-26 Library Functions and the Linker

Computer Science: A Structured Programming Approach Using C 2


FIGURE 4-27 Ceiling Function

Computer Science: A Structured Programming Approach Using C 3


FIGURE 4-28 Floor Function

Computer Science: A Structured Programming Approach Using C 4


FIGURE 4-29 Random Number Generation

Computer Science: A Structured Programming Approach Using C 5


FIGURE 4-30 Generating a Random Number Series

Computer Science: A Structured Programming Approach Using C 6


Note
srand must be called only once for each random
number series.

Computer Science: A Structured Programming Approach Using C 7


PROGRAM 4-9 Creating Temporal Random Numbers

Computer Science: A Structured Programming Approach Using C 8


PROGRAM 4-9 Creating Temporal Random Numbers

Computer Science: A Structured Programming Approach Using C 9


PROGRAM 4-10 Creating Pseudorandom Numbers

Computer Science: A Structured Programming Approach Using C 10


PROGRAM 4-10 Creating Pseudorandom Numbers

Computer Science: A Structured Programming Approach Using C 11


FIGURE 4-31 Random Number Scaling for 3–7

Computer Science: A Structured Programming Approach Using C 12


PROGRAM 4-11 Generating Random Numbers in the Range 10 to 20

Computer Science: A Structured Programming Approach Using C 13


PROGRAM 4-11 Generating Random Numbers in the Range 10 to 20

Computer Science: A Structured Programming Approach Using C 14


PROGRAM 4-12 Generating Random Real Numbers

Computer Science: A Structured Programming Approach Using C 15


PROGRAM 4-12 Generating Random Real Numbers

Computer Science: A Structured Programming Approach Using C 16

You might also like