I'm new to C coding, and could appreciate some help with my doubt. I've recently witnessed strange nature of output in C for int and float values.
int main()
{
int x=1;
while(x==1)
{
printf("%d\n",x);
x=x-1;
}
return 0;
}
According to me, code for int datatype works fine, and I got output as expected.I expect the same for float datatype, but it shows no output. I don't understand this.
//Same code for float
int main()
{
float x=1.1;
while(x==1.1)
{
printf("%f\n",x);
x=x-0.1;
}
return 0;
}
NOTE that when i put x=(Any integer) [at both places, in the code], it gives expected output,but whenever i put decimal, it doesn't give output as i expect for code with int. This is my first time and first question on Stack Overflow. I would appreciate some tips.English is not my first language, kindly bear with me.