![]() |
printf() unusual behavior
Hi friends...
void main() { float a=2.45; printf("%d%f",a,a); } what would be the output of above mentioned question and why? plz. help me. thanx in advance. |
Re: printf() unusual behavior
Try running and see what it gets?
|
Re: printf() unusual behavior
thanx...
It gives unexpected output... let me tell u an example void main() { float a=0.7; printf("%d%f",a,a); } output :--------- 0 and 0.0000000 |
Re: printf() unusual behavior
what about this
printf(%d%f,(int) a,a); |
Re: printf() unusual behavior
Change your declaration to
float a = 0.7f; and see whats the output. |
Re: printf() unusual behavior
nothing is heppened.
it b/c float takes the 4bytes in stact memory of type floating point, but if our program give him a integer value than it's will converted into 0 or 0.00000000, |
| All times are GMT +5.5. The time now is 15:06. |