A function is declared with a prototype. The function prototype consists of the return type, a function name and parameter list. The results of a function is referred to as its return value, and they type of the return value is called the function return type. A function is generally represented by a name. The parameters are specified in parentheses separated by commas. The actions performed by a function are specified in the body of the function. The function body is enclosed in curly braces and is sometimes referred to as the function block. The function prototype in curly braces and is sometimes referred to as the function block. The function prototype is also called the function declaration. The form of C function is
return – type function_ name (type1 arg1, type2 arg2,….. typen argn)
{
local variable declaration;
executable statements;
……………
}
return – type represents the data type of the value that is returned by the function. function _ name represents the name of the function. type1, type2,…….typen represents the data types of arguments arg1, arg2,…….argn. The data types are assumed to be of type int if they are not shown explicitly, but in good programming practice return – type should be mentioned.
Here the arguments are called formal (dummy) arguments because the value of the actual arguments are transferred into these arguments. They are also known as formal (dummy) parameter. The actual argument or actual parameter are those arguments used in function reference. Each formal argument must be of the same data type as the data item it receives from the calling portion of the program. For example:
Float addition (float x, float y, float z)
{
Floats;
s = x + y + z;
return s;
}
In the above function, float is the data type returned by the function. The name of the function is addition and the formal arguments are x, y and z.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc