

If we try to jumble the arguments then it gives the type mismatch error. Kotlin function mul() to multiply two numbers having same type of parameters-Įxplanation- In the above program, we are calling the student() function by passing the arguments in the same order as required. ): return_type – Curly braces represent the block of function. Generally we define a function as: fun fun_name(a: data_type, b: data_type. In Kotlin, function can be declared at the top, and no need to create a class to hold a function, which we are used to do in other languages such as Java or Scala. Each defined function has its own properties like name of function, return type of a function, number of parameters passed to the function etc. As we know, to divide a large program in small modules we need to define function. compareTo() – To compare two numbers and return boolean value.Ī function which is defined by the user is called user-defined function.toInt() – To convert a number to integer value.

rem() – To find the remainder of one number when divided by another.print() – Used to print a message to standard output.sqrt() – Used to calculate the square root of a number.The list of different standard library functions and their use – Output: The remainder when 26 is divided by 3 is: 2 ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.DevOps Engineering - Planning to Production.Python Backend Development with Django(Live).Android App Development with Kotlin(Live).Full Stack Development with React & Node JS(Live).Java Programming - Beginner to Advanced.Data Structure & Algorithm-Self Paced(C++/JAVA).Data Structures & Algorithms in JavaScript.Data Structure & Algorithm Classes (Live).
