I would start with line 15, what exactly was that supposed to do?
basically what you said with this code:
for (number = intone; number <= inttwo; number++)
is if you input number1 : 4, and number2: 8
it would start the loop with number equaling 4, then it will increment by 1, until number equals 8.
if you output you would probably get something like
number: 4
number: 5
number: 6
number: 7
number: 8 |
fix number two you could do:
line 18 code:
sum = sum + inttwo;
is the same thing as
sum += inttwo;
but im pretty sure you meant something like this
sum = intone + inttwo //setting sum1 equal to number 1 + number 2.
fix number 3 you could do:
line 16 code:
while ( intone %2 != 0 && inttwo % 2 != 0)
is a very bad idea that would mean if both the numbers are odd you want to set the sum equal to the sum of the two numbers for infinte amount of time.
you could either a) use an if statement instead of while
or b) put a break at the end of the while loop.
if you are trying to check if the number is an odd by that
and basically you said that if both numbers are odds you want to add them together.
but if you want to add each odd number seperatly to the total sum you would have to do something like
1 2
|
if(intone % 2 == 1) sum += intone; // or != 0
if(inttwo %2 == 1) sum += inttwo; // or != 0
|