Hello,
i have following code in C++
#include <iostream>
using namespace std;
int main()
{
int i;
while(1)
{
cout<<"Enter a number";
cin>>i;
if(i==1)
break;
}
return 0;
}
After running this code, if i enter a floting precision value - E.g. 2.3 for i
then the code goes into infinite loop.
Interestingly if i enter 1.1 or 1.36 for i then the infinite loop doesnt
encountered - since the break statement is reached.
I have tried it on Visual Studio 6.0. Can anybody tell me the reason?
I did also tried the same code using printf scanf but the same problem occurs
for this code also -
Note- this is .c file
#include <stdio.h>
int main()
{
int i;
while(1)
{
printf("Enter a number");
scanf ("%d", &i);
if(i==1)
break;
}
return 0;
}
Why delete messages? Unlimited storage is just a click away. Go to
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html