Advertisements
Advertisements
प्रश्न
What happens if you modify a variable outside the function? Give an example.
टीपा लिहा
Advertisements
उत्तर
When a function depends on variables or functions outside of its definition block, you can never be sure that the function will behave the same every time it’s called.
For example let y: = 0
(int) inc (int) x
y: = y + x;
return (y)
In the above example, the value of y gets changed inside the function definition due to which the result will change each time. The side effect of the inc ( ) function is it is changing the data ‘ of the external visible variable ‘y’.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
