Hello. I've been working on this for a while for my self study and have managed to get most of it underway. The problem seems to be trying to get the correct total of adding up all the odd numbers on the right-hand side.. When I input the values of 17 and 19 I get the value 0 back which confuses me because I can't see how that's possible... Maybe I just need more experience. Can anyone help me please?
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int number;
int number2;
int sum = 0;
printf("Enter one number");
scanf("%d",&number);
printf("Enter one more number.");
scanf("%d",&number2);
do
{
printf("%d\t%d\n",number,number2);
number = number / 2;
number2 = number2 * 2;
if(number2 % 2 == 1)
{
sum = sum + number2;
}
}
while(number!=0);
printf("%d",sum);
}