What is the bug in the following code (Hint: It istechnically called an off-by-one error)? int n,
Fantastic news! We've Found the answer you've been seeking!
Question:
int n, sum = 0;
for (n=1; n<10; n++)
sum = sum + n;
System.out.println("1 + 2 + ...+9 + 10 ==" + sum);
Related Book For
Discrete and Combinatorial Mathematics An Applied Introduction
ISBN: 978-0201726343
5th edition
Authors: Ralph P. Grimaldi
Posted Date: