All about Basics of C main() function

All about Basics of C main() function

main( ) function , 
main() function , 
main() , 
basics of main() function
Forms of main( ) function

1 – main( ) function is a part of every C programme

2 – C permits different forms of main( ) function.

3 – The allowed forms are viz. :

  • main( )
  • main( void )
  • void main( )
  • void main( void )
  • int main( )
  • int main( void )

[mi_note radius=”10″]4 – These ( ) , empty parenthesis indicates that a function has – no arguments , OR – no parameters , OR – no inputs Or simply means it will take nothing [/mi_note]

[mi_box title=”NOTE:”]5 – void means – nothing [/mi_box]

6 – So, if we write main( void ) means the same i.e. it has –

  • no arguments OR
  • no parameters OR
  • no inputs OR
  • nothing it will take as input

7 – Note: Function Structure : return-type functionname( arguments) { body; }

8 – If we write int before main( ) function means that , the main( ) function should return an integer value ( int means integer ).

9 – So, if we write int before main( ) then, it is compulsory to write ” return 0 ” as the last statement of the programme.

Read Basic Structure of C

Read Importance of C Lang.

Read History of C

10 – void before main( ) means it will return nothing.

# if we write void before main( ) , it means nothing , it will return nothing & if we write only main( ) it also means the same i.e. it’s return type is void and hence not return any value. So, for our simplicity we write main( ) .

!! if we write main( void ) or main( ) both means it will take nothing as argument.

Finally , we concluded that for our simplicity we write main( ) simply.

[mi_heading size=”20″ margin=”30″]Key Points of main( ) function[/mi_heading]

1 – Every programme exactly must have one main( ) function.

2 – If we use more than one main( ) function , the compiler can’t understand which one marks as the beginning of the programme.

format of c program ,
main function ,
structure of simple c program
format of simple C Program

3 – { , opening braces after main( ) indicates the logical opening of the programme

Read Basic Structure of C

Read Importance of C Lang.

Read History of C

4 – } , closing braces indicates the logical ending of the programme

5 – All statements between these pair of brace ( { } ) , forms Function body.

6 – The information contained between parentheses ( ) is called the ” arguments ” .

[mi_posts posts_per_page=”-1″ tax_term=”149″]

Leave a Reply

Close Menu