[getting started] can the following program be rewritten into a loop program?

this is the program to get what is in each decimal bit of five digits, and can the parts of ten digits, hundred digits and thousands of digits be rewritten into a loop structure?

/-sharpinclude < stdio.h >

int main (void)
{
int x = 0;
short x0 direction x1scorex2Lecture x3Powerx4;
printf ("\ n Please enter a 5-digit integer:");
scanf ("% d", & x);

)

x0roomx% 10;
x1mmx% 100max 10;
x2roomx% 1000max 100;
x3roomx% 10000max 1000;
x4roomx 10000;

printf ("\ nbits =% d\ nTen digits =% d\ n100 digits =% d\ n1000 bits =% d\ n\ n", x0Personx1Personx2Personx3Personx4);
return 0;
}

C
Dec.01,2021

you can definitely do it, but you don't have to use a loop.
if you use sprintf, you can

.
char res[6];
sprintf(res, "%5d", x);
printf("\n=%c\n=%c\n=%c\n=%c\n=%c\n\n",res[4],res[3],res[2],res[1],res[0]);

upstairs positive solution, it is more convenient to get each of the five digits using the char array

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea6ead-47bf7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea6ead-47bf7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?