Home > Back-end >  While (I) in the I for floating-point, cause the program to death cycle, unable to enter
While (I) in the I for floating-point, cause the program to death cycle, unable to enter

Time:01-16

Do the exercises a c + +, input integer and output the total and asked me, I'll use a while loop, the end of the cycle condition is 0, but I input integer ok, input with decimal floating point system has been input output self, self plus one loop,
//exercise 5.3 write input digital applications, the output end is 0, input, the program automatically output of accumulative and so far, 
#include
using namespace std;
Int main () {
Long I, ll sum=0;
Cout & lt; <"Both Please enter a number:";
Cin & gt;> i;
While (I) {
Sum=sum + I;
Cout & lt; <"The total of The Numbers which was inputed is:" & lt; Cout & lt; <"Both Please enter another number:";
Cin & gt;> i;
}
system("pause");
return 0;
}

CodePudding user response:

VS2015 compile operation, there is no problem, you said

CodePudding user response:

99.0 try you input

CodePudding user response:

Ok, no problem, got the wrong type, to define the two integers, change it

CodePudding user response:

Because of you to the first cin is 90.0, actually I only read the 90 did not read. 0 then cin> cycle;> I read. Read and failure. 0 0 there has been a stream will be infinite
  • Related