clock() function in C/C++
The clock() function is defined in the ctime header file. The clock() function returns the approximate processor time that is consumed by the program. The clock() time depends upon how the operating system allocate resources to the process that’s why clock() time may be slower or faster than the actual clock.
clock_t clock( void );
Parameters: This function does not accept any parameter.
Return Value: This function returns the approximate processor time that is consumed by the program and on failure function returns -1.
Below program illustrates the implementation of clock() function:
Processor time taken for multiplication: 0.006485 seconds Processor time taken in pow function: 0.022251 seconds