printf("Enter the 5 digit number");
int num;
scanf("%d", num);
int n1=num%10;
int n2=num-n1;
int n3=n2%10;
int n4=n2-n3;
int n5=n4%10;
int n6=n4-n5;
int n7=n6%10;
int n8=n6-n7;
int n9=n8%10;
int sum=n1+n3+n5+n7+n9;
printf(" The sum of the digits is %d", sum);
If your code was to find the sum of the digits of a number
Below is the correct code
include <stdio.h>
int main()
{
//define the variables user input, sum and the remainder
//read the user input first of all
//make sure sum is initialised to 0
int num, sum = 0, rem;
printf("Enter the 5 digit number");
scanf("%d", &num);
while(num > 0)
{
//get the remainder of num divided by 10 and add it to the sum
//divide num by 10
rem = num % 10;
sum = sum + rem;
num = num / 10;
//all this is when the number isnt zero
}
//print the result
printf(" The sum of the digits is %d", sum);
}