Home > Back-end >  Would you please tell me why you this for loop does not perform?
Would you please tell me why you this for loop does not perform?

Time:10-30

From the keyboard to enter a positive integer, sigma and

CodePudding user response:

Sum=sum + ((double) (I + 6)/(I + 1));//first converted to a double, otherwise (I + 6)/(I + 10) in terms of int is 0, 0 to double up (the sum is double), doesn't make sense

CodePudding user response:

reference 1st floor qybao response:
sum=sum + ((double) (I + 6)/(I + 1));//first converted to a double, otherwise (I + 6)/(I + 10) in terms of int is 0, 0 to double up (the sum is double), meaningless

Thank you very much! A success, I also try to add before but didn't succeed where (should write wrong), it is ok to this time

CodePudding user response:

reference 1st floor qybao response:
sum=sum + ((double) (I + 6)/(I + 1));//first converted to a double, otherwise (I + 6)/(I + 10) in terms of int is 0, 0 to double up (the sum is double), meaningless

Thank you very much! A success, I also try to add before but didn't succeed where (should write wrong), it is ok to this time
  • Related