0% found this document useful (0 votes)
38 views1 page

User Define Function

The document discusses how to declare and define functions in C++. It states that the function declaration uses a prototype to specify the name, return type, and parameters. This is placed before the main function. The function definition then implements what the function will do and must match the prototype exactly except for a semicolon. The definition is placed after the main function.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

User Define Function

The document discusses how to declare and define functions in C++. It states that the function declaration uses a prototype to specify the name, return type, and parameters. This is placed before the main function. The function definition then implements what the function will do and must match the prototype exactly except for a semicolon. The definition is placed after the main function.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

   Declare the function.  The declaration, called the function prototype, tells the
computer the name, return type, and parameters of the function.  This statement is placed after
#include<iostream.h> (and other headers) and before
int main(void).

2.  Define the function.  The function definition tells the compiler what task the function will
be performing.  A function definition cannot be called unless the function is declared.  The
function prototype and the function definition must agree EXACTLY on the return type, the
name, and the parameters.  The only difference between the function prototype and the function
header is a semicolon (see diagram below).  The function definition is placed AFTER the end of
the int main(void) function.

The function definition consists of the function header and its body.  The header is
EXACTLY like the function prototype, EXCEPT that it contains NO terminating semicolon.

You might also like