Can sombedoy explain me how can I input float and double numbers in c?
Can I put for exaple 0.54x10E45?
Which must be the syntax of the input for single and double?
thanks
Can sombedoy explain me how can I input float and double numbers in c?
Can I put for exaple 0.54x10E45?
Which must be the syntax of the input for single and double?
thanks
Code:#include <stdio.h> int main(void) { double value; fputs("value? ", stdout); fflush(stdout); if ( scanf("%lf", &value) == 1 ) { printf("value = %g\n", value); } return 0; } /* my output value? .54E45 value = 5.4e+44 */
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Could you explain pīlease? Remember the question is how do the user can enter the float and double numbers? I did a program that sums two numbers but How can they ENTER on the keyboard the numbers if they need to add exponents?
Look at the part in blue -- omit the x10 part of what you originally stated.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Thanks. Now what about if I need to valide the input?
user can enter for example
Please enter first value (examples value= .54E45 or value = 5.4e+44)
If the user tries to enter something different than this kind of number how can I validate this?
FAQ > How do I... (Level 2) > Validate user input
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Thanks