Hi everyone, I've got a question on C programming (I'm not sure if I've got the right to post it on this forum...) :I wonder how we can get rid of the "useless" zeros in the following code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
double poids=0;
scanf("%lf",&poids);
printf("Vous pesez %lf kg.",poids);
return 0;
}
When the user enters 60.5, the computer answers somthing like 60.500000000... How can we get rid of them?
Thank you in advance.
Thank you Akshit. It worked ;)
Do you know as well if there is a way we can reproduce the number as in C++?I mean if you don't know the precision pf a number entered by the user for instance, you'll put ."how much"...
Thanks anyway :)
Well, what I meant was : is there a way in C (as there is in C++) to re-write the number entered by the user on the console as they entered it? For example they enter 13.4 and in C++ we write cin >> number and the console shows:13.4, now if it's 13.45 the console shows: 13.45.
In C if we have to mention the precision each time, how can we know which precision we should choose, since we don't know what was the precision of the number entered by the user?
Thank you :)