Program 57 #P57 - C Program to add two number's using a UserDefined Function #C176
Syntax of function prototype
returnType functionName(type1 argument1, type2 argument2,...);
In the above example, int addNumbers(int a, int b); is the function prototype which provides following information to the compiler:
name of the function is addNumbers()
return type of the function is int
two arguments of type int are passed to the function
The function prototype is not needed if the user-defined function is defined before the main() function.
Passing arguments to a function
In programming, argument refers to the variable passed to the function. In the above example, two variables n1 and n2 are passed during function call.
The parameters a and b accepts the passed arguments in the function definition. These arguments are called formal parameters of the function.
The type of arguments passed to a function and the formal parameters must match, otherwise the compiler throws error.
If n1 is of char type, a also should be of char type. If n2 is of float type, variable b also should be of float type.
A function can also be called without passing an argument.
Return Statement
The return statement terminates the execution of a function and returns a value to the calling function. The program control is transferred to the calling function after return statement.
In the above example, the value of variable result is returned to the variable sum in the main() function.
Syntax of return statement
return (expression);
For example,
return a;
return (a+b);
The type of value returned from the function and the return type specified in function prototype and function definition must match.
#rubalsolutions #coding #developer #programming #programmer #technology #clanguage #computerscience #c #informaticpractices #sub #subscribe #youtube #newyoutuber #youtubechannel
To Install Turbo C++ 4.5 Click on Below Link and Download rar file and extract and then install..
https://app.box.com/s/soz2137zo0rv0sb...
Do Like,Comment,Share and Subscribe if u are learning little bit.
Please give me suggestions in form of comment box .
Link To My Blog - https://www.blogger.com/blogger.g?blo...
Like me on Facebook @ https://www.facebook.com/rubalsolutions/
Follow me on Twitter @ https://twitter.com/ruby0071
Follow me on Instagram @https://www.instagram.com/er.rubal/
Email me at :- ruby0071@gmail.com