English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Why strlen is called pure function? - Computer Science

Advertisements
Advertisements

Question

Why strlen is called pure function?

Short Note

Solution

strlen (s) is called each time and strlen needs to iterate over the whole of ‘s’. If the compiler is smart enough to work out that strlen is a pure function and that ‘s’ is not updated in the lbop, then it can remove the redundant extra calls to strlen and make the loop execute only one time. This function reads external memory but does not change it, and the value returned derives from the external memory accessed.

shaalaa.com
Pure Functions
  Is there an error in this question or solution?
Chapter 1: Function - Evaluation [Page 9]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 1 Function
Evaluation | Q 2. | Page 9
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×