Basically this problem is very simple, but you have to think about how to getting the numbers. Iam asking the user for a 6 digit number so i divide by 100,00 and then get the remainder of %100,000 of the same digit and then continue with the same logic until i reach the number / 1 and then %1.
The logic is that the number is / and then %. This is all the program is doing you have to know how the % (remainder) works and thats it.
My advice is to get a piece of paper and work it out how the program is getting solve and eventually you will get the picture. Is just some basic calculations. I have commented the code to help you... Hope it helps you.
Code:
#include <stdio.h>
int main()
{
int num;
printf("Enter a six-digit number:");
scanf("%d", &num);
printf("%3d",num/100000);num=num%100000; // 6 digit number is divided by 100,000 and then optain remainder %100,000
printf("%3d",num/10000); num=num%10000; // 5 digit is divide by 10,000 obtain remainder %10,000
printf("%3d",num/1000); num=num%1000; // 4 digit is divided by 1000 obtain remainder %1000
printf("%3d",num/100); num=num%100; // 3 digit is divide by 100 %1000
printf("%3d",num/10); num=num%10; // 2 digit is divide by 10 %100
printf("%3d",num/1); num=num%1; // 1 digit is divide by 1 %1 same logic
printf(" \n");
return 0;
}