Questions tagged [function-definition]

Use this tag for questions specifically about the rules, syntax, or behavior of function definitions but not for questions that happen to have code with function definitions in them but are not about function definitions.

Only use this tag if the issue at hand is about or related to the function definition.

A function definition is the definition of a user defined function along with the code the function contains. This is distinct from which only defines the name and arguments of a function in certain programming languages. Example in C:

void SayHello(void); // Function declaration

void SayHello(void) { // Function definition
    puts("Hello world!");
}

Some languages do not have function declarations and only have function definitions. Example in JavaScript:

function SayHello() { // Function definition; no forward declaration is required in JavaScript
    console.log("Hello world!")
}

Function definitions are very common in programming. Many questions will contain them, but only use this tag if they are part of the question, and not just part of code being used to demonstrate an unrelated problem. Consider using other tags in these cases:

  • Use if the question is about functions in general.
  • Use if the question is about forward declarations of functions and not about defining the code of the function.
963 questions
-4
votes
2 answers

How to return boolean in a function?

I wanted to compare two arrays. I have set a variable as true and it gets false, when any element in an array does not match. I want to return that variable, which is a boolean, but it does not return that. Why is that? bool compare_arr(int arr1[],…
-5
votes
1 answer

Why is the answer submitted wrong

#include void f(char *s[],int n) { int i=0; int j=0; int x=0; int k=i; for (x=0;x*(*(s+j+1)+i)) …
-11
votes
2 answers

how to display common character if the two letters is equal in vector

For example I have vector {'a','a','b','b','c'} and I want to get the most letters which is a and b but this code the output is a; #include #include #include #include int…
anony
  • 42
  • 7
1 2 3
64
65