Handling Non Integer Function
- We have already learnt that the Function can either return no value or integer values.
- The Function that return no value is declared as void.
- So we have been prefixing int to Functions which return integer values.
- This is valid but unnecessary because the default return value of a function in C is of type int.
- Thus the following two declarations are equivalent in the sense that we need not prefix int to a function which return integer value.
C Language Notes
int 1cd (int a, int b);
1cd (int a, int b);
- on the other hand, whenever a function returns non integer values. The function must be prefixed with the appropriate type.
e.g. a function abc that returns a valeuof type float can be declared as shown below:
float abc(...)
{
float a;
.
.
.
return(a);
}
Similarly a function ABC that returns a value of type char can be declared as:
char ABC(...)
{ char ch;
.
.
.
} return(ch);