Why isn't this code working?
If a four digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of the number. my code... #include <stdio.h> int main() { //prompt the user to input the four digit number int theNum; printf("Enter the four-digit number: "); scanf("%d", &theNum); //compute the sum of the first and the last digits int sum = 0, i; for( i = 4; i > 0; i--) { if (i == 3 || i == 2) theNum = theNum / 10; continue; sum += (theNum % 10); theNum = theNum / 10; } printf("The sum of the entered digits is %d", sum); return 0; } but it's not giving the exact answer. Please can someone explain why it's not working and also the correct program for the question