Function Declaration and Definition

Sunday, December 27, 2024


Function Declaration and Definition

  1. Similar to variable , C Program has to declare function
  2. Function Declaration is Called as 'Function Prototype'
  3. As variables are declared before use , similarly the 'Function Prototype' is declared before using it.
  4. It Provide following information to the Compiler
                >  Name of the Function
                >  Return Type [ Optional / Default-Integer ]
                > Argument List / Parameter List


Note :
  • Prototype always ends with semicolon
  • Parameter List is Optional
  • Default Return Type is Integer


Syntax :       return_type function_name ( type arg1, type arg2...... );


Valid Examples
  1. int sum ( int a ,int b); 
  2. int square ( int a );  
  3. void display(void);
  4. int sum (int,int); 



Facts about Prototype Declaration :
  1. If function Definition is Written after main then and then only we write Prototype Declaration in Global Declaration Section
  2. If function Definition is written above the main function then , no need to write  Prototype Declaration


Bookmark & Share

0 comments:

Total Visits

  © Blogger templates Newspaper by Ourblogtemplates.com 2008

Back to TOP