मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता १२

What are called Parameters and write a note on Parameter with Type? - Computer Science

Advertisements
Advertisements

प्रश्न

What are called Parameters and write a note on Parameter with Type?

थोडक्यात उत्तर

उत्तर

Parameters are the variables in a function definition and arguments are the values that are passed to a function definition.

Parameter with Type

Parameter with Type:
Now let us write the same function definition with types for some reason:
(requires: b > 0 )
(returns: a to the power of b )
let rec pow (a: int) (b: int): int: =
if b=0 then 1 else a * pow b (a-1)

  • When we write the type annotations for ‘a’ and ‘b’ the parentheses are mandatory.
  • There are times we may want to explicitly write down types.
  • This useful at times when you get a type error from the compiler that doesn’t make sense.
  • Explicitly annotating the types can help with debugging such an error message.
shaalaa.com
Function with Respect to Programming Language
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1: Function - Evaluation [पृष्ठ १०]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 12 TN Board
पाठ 1 Function
Evaluation | Q 1. (ii) | पृष्ठ १०
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×
Our website is made possible by ad-free subscriptions or displaying online advertisements to our visitors.
If you don't like ads you can support us by buying an ad-free subscription or please consider supporting us by disabling your ad blocker. Thank you.