
differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples

Difference between local and public variables
public variables once declared they can be used any where in the program i.e. even in many functions while local variables are local to a functional and cant be used beyond that function.
#include <iostream.h>
void myFunction(); // prototype
int x = 5, y = 7; // global variables
int main()
{
cout << "x from main: " << x << "\n";
cout << "y from main: " << y << "\n\n";
myFunction();
cout << "Back from myFunction!\n\n";
cout << "x from main: " << x << "\n";
cout << "y from main: " << y << "\n";
return 0;
}
void myFunction()
{
int y = 10; //local variable
cout << "x from myFunction: " << x << "\n";
cout << "y from myFunction: " << y << "\n\n";
}
Difference between pre-defined and user-defined function
The user-defined functions are defined by a user as per its own requirement while library functions or pre-defined come with compiler.
Example: In the above code, main() function is pre-defined and myFunction() function is user-defined.
A function prototype is a declaration of a function that omits the function body but does specify the function's return type, name, arity and argument types. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.
#include <iostream>
using namespace std;
void printMessage(void); // this is the prototype!
int main ()
{
printMessage();
return 0;
}
void printMessage (void)
{
cout << "Hello world!";
}