C Programming - Functions - Discussion

1. 

Functions cannot return a floating point number

[A]. Yes
[B]. No

Answer: Option B

Explanation:

A function can return floating point value.

Example:


#include <stdio.h>
float sub(float, float); /* Function prototype */

int main()
{
    float a = 4.5, b = 3.2, c;
    c = sub(a, b);
    printf("c = %f\n", c);
    return 0;
}
float sub(float a, float b)
{
   return (a - b);
}

Output:
c = 1.300000


Vivek said: (Jan 16, 2012)  
Can anyone explain it further?

Pradip &Amp; Arpit said: (Feb 25, 2017)  
Ans is A not B.

The function can be return float value.

Serwit said: (Nov 14, 2017)  
@Pradip &Amp; Arpit read question properly.

Swati said: (Jul 17, 2019)  
Can anyone explain this?

The default return type of function is int. Then how can it return float value?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.