Function Declaration and Definition
Sunday, December 27, 2024
Function Declaration and Definition
- Similar to variable , C Program has to declare function
- Function Declaration is Called as 'Function Prototype'
- As variables are declared before use , similarly the 'Function Prototype' is declared before using it.
- It Provide following information to the Compiler
> 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 :
- int sum ( int a ,int b);
- int square ( int a );
- void display(void);
- int sum (int,int);
Facts about Prototype Declaration :
- If function Definition is Written after main then and then only we write Prototype Declaration in Global Declaration Section
- If function Definition is written above the main function then , no need to write Prototype Declaration

0 comments:
Post a Comment