C Programming language

C Standard Library Function

Day 1: Introduction and brief history of C Programming language

Day 1: Advantages and Disadvantages of C, C Keywords, Data type modifiers in C

Day 1: Data types in C Programming language

Day 1: Secondary data types, Primitive and Non-primitive data types

Day 1: C Variables, C Constant, Format Specifiers in C

Day 2: Write first C program

Day 2: Flow of C program with example, main(), printf(), scanf()

Day 2: Operaters in C Programming language, Arithmetic operators

Day 2: Relational operators and Logical Operators in C Programming language

Day 2: Assignment, Increments and Decrement Operators in C Programming language

Day 3: Conditional statement: if else statement in C Programming language

Day 3: Conditional statement: switch statement in C Programming language

Day 3: Jump statements: return statement in C Programming language

Day 3: Jump statements: go to statement in C Programming language

Day 3: Jump statements: break statement in C Programming language

Day 3: Jump statements: continue statement in C Programming language

Day 4: Loops OR Iteration statement in C Programming language: for Loop

Day 4: Loops OR Iteration statement in C Programming language: while Loop

Day 4: Loops OR Iteration statement in C Programming language: do while Loop

Day 5: Array in C Programming language

Day 5: Access elements of Array in C Programming language

Day 5: One dimensional Array representation in memory using C Programming language

Day 5: Two dimensional Array representation in memory using C Programming language

Day 5: Multidimensional Array in C Programming language

Day 6: Function in C Programming language

Day 6: Definition, Declaration and Calling a Function in C Programming language

Day 6: Passing array to a function in C Programming language

Day 6: Calling Function in C Programming language : Call by value

Day 6: Calling Function in C Programming language : Call by reference

Day 6: Recursive Function in C Programming language

Day 6: Adding function to the library in C Programming language

Day 7: Pointer in C Programming language, How to use Pointer, Pointer declaration

Day 7: NULL Pointers in C Programming language

Day 7: Array of Pointers in C Programming language

Day 7: Pointer arithmetic in C Programming language

Day 7: Pointer to Pointer in C Programming language

Day 7: Pointer to Function in C Programming language: Passing pointers to functions

Day 7: Pointer to Function in C Programming language: Return pointer from functions

Day 8: Strings in C Programming language, Declaring String in C Programming language

Day 8: String functions in C Programming language

Introduction of Structure

Accessing the members of Structure

Structure With typedef Keyword and Use of sizeof function

Example of Structure

Dynamic memory allocation in C: Introduction

adplus-dvertising
adplus-dvertising
Day 6 Function in C Programming language: Introduction
Previous Home Next

# Function

A fuction is a self contained block of statement that perform a coherent taskof some kind.

  • Functions are a powerful programming tool
  • A function is a block of code that performs a specific task
  • It has a name and it is reusable
  • It can be executed from as many different parts in a Program as required, it can also return a value to calling program
  • All executable code resides within a function
  • It takes in input, does something with it, then give the answer
  • A C program consists of one or more functions, A computer program cannot handle all the tasks by it self
  • It requests other program like entities called functions in C
  • We pass information to the function called arguments which specified when the function is called
  • A function either can return a value or returns nothing. Function is a subprogram that helps to reduce coding

Defining a Function

A function definition in C programming language consists of a function header and a function body. Here are all the parts of a function:

return_type function_name( parameter list )
{
   body of the function
}

# return_type: A function may return a value. The return_type is the data type of the value the function returns. Some time the return_type is the keyword void, in that case functions perform the desired operations without returning a value.

# function_name: This is the actual name of the function

# Parameters: Its like placeholder. Parameters are optional; that is, a function may contain no parameters. When a function is invoked, you pass a value to the parameter. The parameter list refers to the type, order, and number of the parameters of a function

# Function Body: The function body contains a collection of statements that define what the function does

Note:

  • If a program contain only one function , it must be main()
  • If a program contain more than one function then one must be main()
  • Each function in a program is called sequence specified by the function calls in main()
  • A function can be called from other function but can not be defined in the other function
Previous Home Next