**what is prototype and its purpose with example **

Homework? A prototype tells the compiler about a function such as its return value and parameters. Function prototypes are required if the function has not been previously defined. For example

void foo(char* s)
{
    printf("%s\n", s);
}

int main()
{
   foo("Hello");
}

In the above snippet a function prototype for foo() is not needed because the compiler already knows about the function when it is called from main()

However, in the snippet below a function prototype is required because the compiler knows nothing about the function foo() when it is called from main().

 void foo(char* s); // function prototype

int main()
{
   foo("Hello");
}

 void foo(char* s)
 {
     printf("%s\n", s);
 }