+ 1
Syntax for user defined function
2 ответов
+ 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.