There are a few problems. Your first loop to accept five numbers is not what you want there. It is going to accept five numbers, one at a time, and
Sum
will have their total. This means if you entered "1 2 3 4 5" then
Sum
would be set to 15. To accept a five-digit number you need to omit the loop and the addition to
Sum
and change the format specifier to scanf to "%5d". The resulting code would be this :
scanf( "%5d", &Sum );
Another problem is this line :
for (i=2; i<=Num/2 ;i++);
This loop does not do anything useful. The first issue is the variable
Num
is not set to anything. The second thing is the
for
statement has a terminating semicolon after it. I am really not sure what that is supposed to do. If the loop is used to determine if the value is a prime number then that is not the right way to do it. There are many algorithms available to do this so I will let you find one you like.
The previous time you posted this I attempted to figure out if a number is palindromic and it was actually pretty easy. I peeled of each digit and put them into an array and then evaluated the contents of the array. Actually, I used a vector for that but since you have a five digit number an array of size 5 will work OK. Just has one can determine odd or even using the modulus operator, one can also separate digits using the same modulus operator. For this, you want to use 10 has the divisor and remember to divide by ten to get the next digit.
I hope this is helpful.