R
Red Dragon
Can someone please tell me how I should write scanf to handle double?
This program works fine for float a but not double a, as the print result
at end of program illustrates.
Thanks
Khoon
#include <stdio.h>
int main (void)
{
double a;
a =2.1111;
printf ("Enter a> ");
scanf ("%f", &a);
printf ("a=%4.4f\n",a);
return 0;
}
/*
Result:
Enter a> 555.55
a=2.1111
Press any key to continue
*/
This program works fine for float a but not double a, as the print result
at end of program illustrates.
Thanks
Khoon
#include <stdio.h>
int main (void)
{
double a;
a =2.1111;
printf ("Enter a> ");
scanf ("%f", &a);
printf ("a=%4.4f\n",a);
return 0;
}
/*
Result:
Enter a> 555.55
a=2.1111
Press any key to continue
*/