answersLogoWhite

0

Functions in C Language

Updated: 8/10/2023
User Avatar

Wiki User

12y ago

Best Answer

Functions have many uses. Although it is possible to write all code within a single function (the main function), code becomes harder to read. By separating the code into smaller, simpler functions with meaningful descriptive names, complex code becomes that much easier to both read and maintain. That is, the code becomes self-documenting so there is less need for comments which would otherwise become a distraction.

Each function should be designed such that it does the absolute minimum amount of work required to fulfil its purpose and does that work as efficiently as possible. Although functions can be expensive to call and return, a well-written function can be inline expanded by the compiler thus eliminating the function call altogether. Thus functions become a programming tool which can drastically reduce the amount of duplicate code we need to write.

Ideally, a function should be small enough so that all the code within that function will fit on screen at once. This usually means writing a huge number of low-level functions that do very little work by themselves, and then using these low-level functions as the building blocks for more complex, higher-level functions.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

functions are a block of code that performs a specific task, a simple code that add two numbers can be a function

for e.g

void add_num(int a, int b)

{

printf("%d",a+b);

}

this is a small function which takes two numbers as parameters and prints the result of addition.

you can find more on functions here:

http://thetechnofreaks.com/2011/09/07/8-code-reusability-intrduction-to-functions/

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

This is a function.

int main (int argv, char **argc)

{

/*

** a whole lot of of C Programming code

*/

return 0;

};
functions are a block of code that performs a specific task, a simple code that add two numbers can be a function

for e.g

void add_num(int a, int b)

{

printf("%d",a+b);

}

this is a small function which takes two numbers as parameters and prints the result of addition.

you can find more on functions here:

http://thetechnofreaks.com/2011/09/07/8-code-reusability-intrduction-to-functions/

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

functions are used to reduce the length of program when same instructions has to be used again and again, it also break the program into module as well as it also improve the readability of the program ...

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Instead of learning all such languges (like for commercial application we use cobol&for engineering and scientific application we use fotran etc... )why can't we use one language i.e., 'c' so Dennis ritchie developed 'c' language.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Functions help modularise code. They usually contain code that is repeatedly executed. Using functions helps improve program readability and ease of maintenance.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

a subroutine that returns a value (other than void)

or a subroutine that doesn't (exit is an example)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Functions in C Language
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is nesting of functions in c language?

Impossibility.


What is the differnce between ordinary function and template function of c language?

The c language does not have template functions. That is a c++ thing.


What is the compound in c language?

compound c language is complicated where we need to use many nested functions and loops


What are the in-built function in c plus plus?

C++ built-in functions are those functions that are provided for you as part of the language itself, and includes all of the C standard library functions (all of which were inherited from C) and is expanded upon by the C++ standard template library. C++ implementors may provide additional functions that are platform-specific, however these are not considered built-in functions becuase C++ is a cross-platform language. These are best described as 3rd party functions. The functions you yourself write are known as user-defined functions.


What is an identifier. what are the hearing rods for identifier 'c' language?

An identifier is the names given for labels, functions and variables in the c language.


What are functions in c language?

constants, MAX_(function), etc.


What enhance the basic instructions of c language?

Library functions


How you describe operations of stack ADT using c template functions?

No, because C does not support the concept of template functions. Template functions only exist in C++, never in C.


How do you convert HTML to c code?

You can't. HTML is a markup language. C is a programming language. You can make C generate HTML, but C isn't anything like HTML in the way it functions.


What does 'C date and time functions' refer to?

C date and time functions refer to a group of functions in the standard library of the C programming language that implements time and date operations like conversion between date formats.


Why dynamic binding is not possible for normal C functions?

Dynamic binding is certainly possible for normal C functions. Binding is a function of the binder (linker) and has nothing to do with the language itself.


What is c language functions?

The answer is, "user-defined functions can be written in C (or a language that can be made compatible with C, such as C++). Such functions are compiled into dynamically loadable objects (also called shared libraries) and are loaded by the server on demand. The dynamic loading feature is what distinguishes "C language" functions from "internal" functions - the actual coding conventions are essentially the same for both. (Hence, the standard internal function library is a rich source of coding examples for user-defined C functions.) Two different calling conventions are currently used for C functions. The newer "version 1" calling convention is indicated by writing a PG_FUNCTION_INFO_V1() macro call for the function, as illustrated below. Lack of such a macro indicates an old-style ("version 0") function. The language name specified in CREATE FUNCTION is C in either case. Old-style functions are now deprecated because of portability problems and lack of functionality, but they are still supported for compatibility reasons."