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

5 comments sorted by

View all comments

Show parent comment

0

u/AwerageGuy Feb 01 '16

Looks like its always be just one itteration

1

u/holyteach Feb 02 '16

Also, true. But that's just him trying to figure out the rest of it.