Functions

Functions
Functions
Function examples
No Pass No Return  Pass and No Return  Pass and Return  No Pass and Return
Recursion
Recursion Examples
Inbuilt Functions
Single character inbuilt functions
String innuilt functions
Math inbuilt functions
Date and Time inbuilt function

Function Page :2

1   2   3 

Call by value

 Whenever we deal with functions following points related to the functions should be remembered.

  • Function declaration.
  • Function calling.
  • Function definition.

 Function declaration

 Function declaration is an indication to the system that the specified function is used later in the program. While giving function declaration we have to mention the following

 1.Return type of the function i.e. the type of value of the function is returning back.

2.Name of the function.

3.The list of arguments being passed to the function i.e. list of data types and variable names(optional).

4.The function declaration is terminated by semicolon(;).

Syntax:

 returntype function_name (list of arguments);

Example:

No pass no return

void abc();

void xyz();

Pass and no return

void abc (int x, int y);

void abc (int,int);

void xyz(float,int);

void xyz(int,float,char);

pass and return

int abc(int x,int y);

float abc(int,int);

 

no pass and return

int abc();

float abc();

 

Function calling

Function calling means invoking the function i.e. executing the function.

While calling the function we have to specify the following:

1.variable to receive the value, if function is returning some value (optional).

2.Name of the function being called.

3.List of values/variables/exp being passed to the function , if passed.

4.The function calling is terminated by the semicolon.

Syntax:

 Variable=function_name(list of values/variables);

Example:

No pass no return

abc();

xyz();

Pass and no return

abc(10,20);

abc(x,y);

xyz(a*10,b-4);

pass and return

a=abc(10,20);

  b=xyz(a,b);

no pass and return

a=abc();

  a=xyz();

Function Page :2

 

1   2   3 

C Language Programming Tutorial

C Language Tutorial Home    Introduction to C Language     Tokens     If Condition     goto statement and Labelname     Switch Statements     For loop     While Loop    Do while loop     break and continue    Functions    Recursion    Inbuild Functions    Storage Classes    Preprocessor    Arrays    Pointers     Structures and Unions    File Handling     Projects

Tutorials

Technical Questions

Interview Questions

C Programming
C++ Programming
Class 11 (Python)
Class 12 (Python)
C Language
C++ Programming
Python

C Interview Questions
C++ Interview Questions