New course! Every coder should learn Generative AI!
Try a free lesson+ 2
What is meant by return type?
3 Answers
+ 4
The data type that the function should return after its execution is called 'return type' of the function.
For example, consider this function declaration:
int Sum(int, int);
In this function, I can use 'return' keyword to return any 'int' type variable from the function. When the 'return' happens, the function execution ends and the code flow is redirected back to the calling function.
Example code with function definition::
int main()
{
int result = Sum(22, 13);
return 0;
}
int Sum(int a, int b)
{
return a+b;
}
Here 'main' (calling function) calls the function 'Sum' by passing two 'int' parameters '22' and '13'. The function uses 'return' to pass back the sum of two passed parameters. This returned type is stored into 'result' in the main function after execution of 'Sum'. Thus 'int' type is returned from the function. It is NOT necessary to use the 'result' to call the Sum function. The 'int' type will be returned from 'Sum' unconditionally. Its the user's c
+ 1
Return Type means Function will going to return Which kind of value.
0
return type means which type of value is return by the function it can bt void int float etc
it returns the value to the calling function