C Programming - Floating Point Issues - Discussion

Discussion Forum : Floating Point Issues - Yes / No Questions (Q.No. 1)
1.
Will the printf() statement print the same values for any values of a?
#include<stdio.h>
int main()
{
    float a;
    scanf("%f", &a);
    printf("%f\n", a+a+a);
    printf("%f\n", 3*a);
    return 0;
}
Yes
No
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
13 comments Page 2 of 2.

Ganesh Raj said:   9 years ago
It is not a^3 here. It's just 3*a. Then, how comes 387.064?

Kelvin desai said:   9 years ago
@Rupesh Sahu.

It is 25.4 * 3 not 25.4 * 25.4 * 25.4.

Vishnuprabhu said:   1 decade ago
But will it be applicable for all the float values?


Post your comments here:

Your comments will be displayed after verification.