Check the following prog:
main()
{
float result;
result =50/100;
printf("%f",result);
}
what is the output?
The output is not like this: 0.50000
The output is 0.000000
because
int/int = int
so change the program to
main()
{
float result;
result=50/100.0;
printf("%f",result);
}
the above programm is (int/float)
so the output is now 0.500000
conclusion:
int/int = int
int/float = float
float/int = float
float/float = float
The above table can be summarized as: integer division takes place only when both elements are integers.
3 comments:
Good Work Started by Akter.....congrats ....for this blog spot...
Sijee, as i fondly call him and have learnt C from him only...now this blogspot has given a common platform for Pointer lover's, let's hope we continue blogging..
Suriya..Is an Master in C & C++
and he wrote two book in C
(c is sea vol i, ii).
and he is good teacher too.
I wish him my best wishes to him
for this new effort............
Post a Comment