1.

What do you mean by function in ‘C’?OrWhat is the library function in ‘C’? Explain.

Answer»

Introduction: Sometimes, to perform a particular task in a program, you may have to write another program which may be a very cumbersome process. Functions are very useful to read, write, debug and modify complex programs. They can also be easily incorporated in the main program. In ‘C’ language, main() itself is a function that means the main function is invoking the other functions to perform various tasks.

There are two types of functions:

  1. Built-in functions/Library Function.
  2. User-defined functions.

1. Built-in Functions/Library Functions: These are the pre-defined routines that are included as an integral part of the language. Each function is accessed simply by stating its name, followed by whatever information must be supplied to the function, enclosed in parentheses (A numeric quantity or a string that is passed to a function in this manner is called an argument). Library functions are also called standard functions or elementary functions. These functions provide a quick and easy way to evaluate many mathematical functions and to carry out certain logical operations.

There are several library functions in ‘C’ Language. Basic Library functions are of two types:

  • String Functions: String functions operate on strings, e.g., strlen (), strrev()
  • Numeric Functions: Numeric functions operate on numeric values, e.g., ABS(), EXP(), SIN(), cos().

2. User-defined Functions: This feature allows you to define functions within a program, which you can call whenever you need them. While running the program (FUNC) statement can save space as well time, as a complex calculation can be defined with a short name and called up by its name where needed.



Discussion

No Comment Found