+ 1

Syntax for user defined function

28th Mar 2020, 11:43 AM
V Sandralega
V Sandralega - avatar
2 Respuestas
+ 3
return_type function_name( parameter list ) { body of the function } This will work if used before the main(). If you want to put body after main() than you need to declare it above main like so : return_type function_name( parameter list ); and than after main you define it using the previous syntax. i.e. this : return_type function_name( parameter list ) { body of the function } Eg : void print_nothing () { printf("nothing"); } int main(){ print_nothing(); return 0; } OR the same can be done in this way : void print_nothing(); int main(){ print_nothing(); return 0; } void print_nothing () { printf("nothing"); } Both are possible ways.
28th Mar 2020, 11:53 AM
Atharva Joglekar
Atharva Joglekar - avatar