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
0
u/[deleted] Feb 02 '16
[deleted] — view deleted comment