+1

Syntax for user defined function

c

3/28/2020 11:43:28 AM

V Sandralega

2 Answers

New Answer

+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.

+1

I see that you only have 10 XP in your C course at the moment. Try completing the lessons in the course and this will be explained. Don't try to run before you can walk.