Syntax of function declarator
return_type function_name(type(1) argument(1),....,type(n) argument(n))Syntax of function declaration and declarator are almost same except, there is no semicolon at the end of declarator and function declarator is followed by function body.
In above example,
int add(int a,int b) in line 12 is a function declarator.Function body
Function declarator is followed by body of function inside braces.Passing arguments to functions
In programming, argument(parameter) refers to data this is passed to function(function definition) while calling function.In above example two variable, num1 and num2 are passed to function during function call and these arguments are accepted by arguments a and b in function definition.
Arguments that are passed in function call and arguments that are accepted in function definition should have same data type. For example:
If argument num1 was of int type and num2 was of float type then, argument variable a should be of type int and b should be of type float,i.e., type of argument during function call and function definition should be same.
A function can be called with or without an argument.
Return Statement
Return statement is used for returning a value from function definition to calling function.Syntax of return statement
return (expression);For example:
return a; return (a+b);In above example, value of variable add in
add() function is returned and that value is stored in variable sum in main() function. The data type of expression in return statement should also match the return type of function.
1 comments:
Are you willing to know who your spouse really is, if your spouse is cheating just contact cybergoldenhacker he is good at hacking into cell phones,changing school grades and many more this great hacker has also worked for me and i got results of spouse whats-app messages,call logs, text messages, viber,kik, Facebook, emails. deleted text messages and many more this hacker is very fast cheap and affordable he has never disappointed me for once contact him if you have any form of hacking problem am sure he will help you THANK YOU.
contact: cybergoldenhacker at gmail dot com
Post a Comment