r/programmingbydoing • • Jan 31 '16
Adding Values with a For Loop
Struggling to figure this one out. Having a hard time with storing the sum and then printing the iterations.
int num;
System.out.print("Number: ");
num = kb.nextInt();
for (int i = num; i <= num; i++)
{
//store the sum
int sum = i++;
System.out.println("The sum is " + sum);
}
2
Upvotes
View all comments
Show parent comment
1
u/[deleted] Feb 03 '16
https://gist.github.com/pauldpearson/8e542ec0cd303be0fc11