• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C » Pointer » Advantages of Functions in C
Next →
← Prev

Advantages of Functions in C

By Dinesh Thakur

Recall that a function call takes the form

func_ name ( arg_list )

where func _name is the name of the function being called and arg_list is a comma separated list of arguments. The number of arguments, their types and order must be in accordance with the function parameters specified in the function definition. When a function is called, the values specified in arg_list are passed to the function. The called function will usually use or process these values in some way.

A function may return a value. When it does, we can call that function from within an expression. If a function does not return a value or if we are not interested in the value returned, a function call takes the form of a C statement as in func_name ( arg_list ) ;

The examples given below illustrate the various ways in which a function func that returns a value can be called. Note that an argument may be a constant, variable or expression.

x = func(3); /* RHS of an assignment statement */
x = c + func(a+b); /* as an operand in an expression */
printf("%d",func(b)); /* as an argument for another function */
func (a - b * c); /* ignore return value */

When a function is called, execution of the current function is suspended. The argument expressions (if present) are evaluated and their values assigned to the corresponding function parameters, and program control is transferred to the called function. The statements in the called function are then executed, starting from the first executable statement until a return statement is encountered or all the statements have been executed.

When the execution of the called function is complete, control is transferred to the calling function to the point from where the function was called. The return value, if any, is returned in place of the function call.

Advantages of Functions

There are several advantages in using functions. They are discussed below.

1. Functions allow the divide and conquer strategy to be used for the development of programs. When developing even a moderately sized program, it is very difficult if not impossible, to write the entire program as a single large main function. Such programs are very difficult to test, debug and maintain. The task to be performed is normally divided into several independent sub tasks, thereby reducing the overall complexity; a separate function is written for each sub task. In fact, we can further divide each sub task into smaller sub tasks, further reducing the complexity.

2. Functions help avoid duplication of effort and code in programs. During the development of a program, the same or similar activity may be required to be performed more than once. The use of functions in such situations avoids duplication of effort and code in programs. This reduces the size of the source program as well as the executable program. It also reduces the time required to write, test, debug and maintain such programs, thus reducing program development and maintenance cost.

3. Functions enable us to hide the implementation details of a program, e. g., we have used library functions such as sqrt, log, sin, etc. without ever knowing how they are implemented. However, although we need to know the implementation details for user-defined functions, once a function is developed and tested, we can continue to use it without going into its implementation details. Another consequence of hiding implementation details is improvement in the readability of a program. Proper use of functions leads to programs that are easier to read and understand.

4. The divide and conquer approach also allows the parts of a program to be developed, tested and debugged independently and possibly concurrently by members of a programming team. The involvement of several programmers, which is the norm in the development of a software project, reduces the overall development time.

5. The functions developed for one program can be used, if required, in another with little or no modification. This further reduces program development time and cost.

You’ll also like:

  1. What is Functions? Explain Features of Functions,Types of Functions and Calling a Function
  2. Advantages of using pointers in C
  3. PHP Functions:User-defined functions
  4. Advantages of Database
  5. Void Functions in C
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C Programming

C Programming Tutorials

  • C - History
  • C - Anatomy
  • C - Constants
  • C - Identifiers
  • C - Data Types
  • C - Libraries File
  • C - Header Files
  • C - Basic Language
  • C - Data Types Sizes
  • C - Header Files Importance
  • C - Escape Sequences
  • C - Main() Purpose
  • C - Program Procedure
  • C - Control Statements
  • C - Enumeration Constant
  • C - Add numbers
  • C - Return Statement
  • C - Avoid Goto
  • C - Command Line Arguments
  • C - Switch Case
  • C - Switch Case Limitations
  • C - getchar() and putchar()
  • C - Iteration Statements
  • C - Pass by Value and Reference
  • C - Structures and Unions
  • C - Structure
  • C - Dynamic Memory
  • C - Fgets and Fputs Functions
  • C - Gets() and Puts() Functions
  • C - Armstrong Number
  • C - Storage Classes
  • C - Fibonacci Series
  • C - Precision Setting
  • C - const Parameters

C - Variable & It's Type

  • C - Variables
  • C - Variable Lifetime
  • C - Static Variable
  • C - Register Variable
  • C - Global Variables
  • C - Auto Variables
  • C - Local Variables

C - Operator & Expressions

  • C - Operator
  • C - Boolean Operators
  • C - Bitwise Operator
  • C - Arithmetic Operators
  • C - Modulus Operator
  • C - Ternary Operator
  • C - Expressions
  • C - Arithmetic Expressions

C - Array

  • C - Arrays
  • C - Array Types
  • C - Array Characteristics
  • C - Static Arrays
  • C - Global Arrays
  • C - 3D Arrays
  • C - Dynamic Arrays
  • C - Pointer to 3D Arrays
  • C - Array Elements Hold
  • C - Arrays as Function Parameters
  • C - Accessing Matrix Elements
  • C - File Handling
  • C - Matrix Multiplication
  • C - Dynamic Memory Allocation

C - Searching & Sorting

  • C - Data Structures
  • C - Linear Search
  • C - Bubble Sort
  • C - Merge Sort
  • C - Linked List
  • C - Insertion Sort
  • C - Binary Search
  • C - Selection Sort
  • C - Quick Sort

C - Functions

  • C - Functions
  • C - Functions Advantages
  • C - Void Functions
  • C - Function Call
  • C - Default Return Value
  • C - String functions

C - Pointer

  • C - Pointers
  • C - Type Casting Of Pointers
  • C - Pointer Advantages
  • C - Pointers Initialization
  • C - Vectors and Pointers

C - Differences

  • C - C Vs C++
  • C - Formal Args. Vs Actual Args.
  • C - Keywords Vs Identifiers
  • C - Strings Vs Character Arrays
  • C - Address Vs Dereference Operator
  • C - Goto Vs longjmp
  • C - Declaring Vs Defining Variable
  • C - String Vs Array
  • C - Call by Value Vs Reference
  • C - Structure Vs Union
  • C - For Vs While loops
  • C - Compiler Vs Interpreter

C - Programs

  • C Program Standard Deviation
  • C Program Calculate Tax
  • C Program Sum Series
  • C Program Merge Arrays
  • C Program Euclid’s Algorithm
  • C Program Print Weekdays
  • C Program Sum of Digits
  • C Program Print a list
  • C Program Print Pythagorean
  • C Program Quiz program
  • C Program Display Table
  • C Program Print Comma-Separated
  • C Program Prints Prime Numbers
  • C Program for Print Integer
  • C Program Count Number
  • C Program Print Color Name
  • C Program Print Odd Numbers
  • C Program Calculate area
  • C Program for a Menu
  • C Program Add Two Vectors
  • C Program Array Addresses
  • C Program Division by Zero Error
  • C Program Compare two Dates
  • C Program Tower of Hanoi
  • C Program return 3 Numbers
  • C Program for Prime Numbers
  • C Program for Factorial
  • C Program for Palindrome

Other Links

  • C Programming - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW